| 1 | import { migrate } from "drizzle-orm/node-postgres/migrator"; |
| 2 | import path from "node:path |
| 3 | import { fileURLToPath } |
| 4 | |
| 5 | import { createDatabase } |
| 6 | |
| 7 | /** |
| 8 | * Applies the committed SQL migrations. Runs from the built output, so the |
| 9 | * folder is resolved relative to `dist/`, not the working directory. |
| 10 | */ |
| 11 | async function main() |
| 12 | const migrationsFolder = |
| 13 | path.dirname(fileURLToPath |
| 14 | "..", |
| 15 | "drizzle", |
| 16 | ); |
| 17 | |
| 18 | const { db, |
| 19 | |
| 20 | try { |
| 21 | await migrate(db |
| 22 | console.log(`Migrations applied from |
| 23 | } finally { |
| 24 | await pool.end |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | await main(); |