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