fp/services/migrations/index.js

29 lines
815 B
JavaScript
Raw Normal View History

2024-07-30 20:34:25 +00:00
import {migrate} from 'postgres-migrations'
import path, { dirname } from 'node:path'
import { fileURLToPath } from 'url';
import 'dotenv/config'
const __dirname = dirname(fileURLToPath(import.meta.url));
if (!process.env.DATABASE_PASSWORD) throw new Error('DATABASE_PASSWORD is missing in env');
async function main() {
const dbConfig = {
2024-08-04 16:40:13 +00:00
database: "futureporn",
2024-07-30 20:34:25 +00:00
user: "postgres",
password: process.env.DATABASE_PASSWORD,
host: 'postgresql-primary.futureporn.svc.cluster.local',
port: 5432,
// Default: false for backwards-compatibility
// This might change!
ensureDatabaseExists: true,
// Default: "postgres"
// Used when checking/creating "database-name"
2024-07-30 20:50:30 +00:00
defaultDatabase: "postgres"
2024-07-30 20:34:25 +00:00
}
await migrate(dbConfig, path.join(__dirname, "./migrations/"))
}
main()