21 lines
No EOL
567 B
TypeScript
21 lines
No EOL
567 B
TypeScript
import { drizzle } from 'drizzle-orm/node-postgres'
|
|
import pg from 'pg'
|
|
import * as migrations from './src/migrations/index.ts'
|
|
|
|
async function main() {
|
|
const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL })
|
|
const db = drizzle(pool)
|
|
|
|
for (const [name, fn] of Object.entries(migrations)) {
|
|
if (typeof fn === 'function' && name === 'up') continue
|
|
if (typeof fn === 'function') {
|
|
console.log(`running: ${name}`)
|
|
await fn({ db })
|
|
}
|
|
}
|
|
|
|
console.log('all migrations done')
|
|
await pool.end()
|
|
}
|
|
|
|
main().catch(console.error) |