7582c64709
Standalone Next output, migration script run on start, storage volume at /app/storage, port 4700. Database connection is created lazily so the image builds without a database.
19 lines
495 B
JavaScript
19 lines
495 B
JavaScript
import { migrate } from 'drizzle-orm/node-postgres/migrator'
|
|
import { drizzle } from 'drizzle-orm/node-postgres'
|
|
import pg from 'pg'
|
|
|
|
const url = process.env.DATABASE_URL
|
|
|
|
if (!url) {
|
|
console.error('[migrate] DATABASE_URL is required')
|
|
process.exit(1)
|
|
}
|
|
|
|
const pool = new pg.Pool({ connectionString: url, max: 1 })
|
|
const db = drizzle(pool)
|
|
|
|
console.log('[migrate] running logbuch migrations')
|
|
await migrate(db, { migrationsFolder: './drizzle' })
|
|
console.log('[migrate] done')
|
|
await pool.end()
|