Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Looskie committed Feb 21, 2024
1 parent ae6c27a commit c403c50
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions apps/api/src/db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,30 @@ import { Logger } from "../utils/logger";
export let db: ReturnType<typeof drizzle>;

export const setupDB = async () => {
setTimeout(() => {
const pool = await new Pool({
connectionString: env.DATABASE_URL,
const pool = await new Pool({
connectionString: env.DATABASE_URL,
})
.connect()
.then((client) => {
Logger.info("INIT", "Connected to database");

return client;
})
.connect()
.then((client) => {
Logger.info("INIT", "Connected to database");

return client;
})
.catch((err) => {
Logger.error("INIT", `Failed to connect to database ${String(err)}}`);
process.exit(1);
});
.catch((err) => {
Logger.error("INIT", `Failed to connect to database ${String(err)}}`);
process.exit(1);
});

db = drizzle(pool);
db = drizzle(pool);

await migrate(db, {
migrationsFolder: "../../packages/internal/db/migrations",
await migrate(db, {
migrationsFolder: "../../packages/internal/db/migrations",
})
.then(() => {
Logger.info("INIT", "Migrated database");
})
.then(() => {
Logger.info("INIT", "Migrated database");
})
.catch((err) => {
Logger.error("INIT", `Failed to migrate database ${String(err)}`);
process.exit(1);
});
}, 1000)
.catch((err) => {
Logger.error("INIT", `Failed to migrate database ${String(err)}`);
process.exit(1);
});
};

1 comment on commit c403c50

@hop-deploy
Copy link

@hop-deploy hop-deploy bot commented on c403c50 Feb 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deployment Status Build Logs Updated At
imperial ✅ Deployed View Logs 2024-02-21T23:44:02.867Z

Please sign in to comment.