fp/services/migrations/index.js

29 lines
814 B
JavaScript

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 = {
database: "postgrest",
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"
defaultDatabase: "postgres"
}
await migrate(dbConfig, path.join(__dirname, "./migrations/"))
}
main()