Skip to content

Commit 917331d

Browse files
HyteqHyteq
authored andcommitted
feat: migrate db on build-time
1 parent c74abe8 commit 917331d

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

packages/db/src/client.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { drizzle } from 'drizzle-orm/node-postgres';
2+
import { migrate } from 'drizzle-orm/node-postgres/migrator';
23
import * as schema from './drizzle/schema';
34
import * as relations from './drizzle/relations';
45

@@ -11,4 +12,10 @@ if (!databaseUrl) {
1112
throw new Error('DATABASE_URL is not set');
1213
}
1314

14-
export const db = drizzle(databaseUrl, { schema: fullSchema });
15+
export const db = drizzle(databaseUrl, { schema: fullSchema });
16+
17+
const migrateDb = async () => {
18+
await migrate(db, { migrationsFolder: 'drizzle/migrations' });
19+
}
20+
21+
migrateDb();

0 commit comments

Comments
 (0)