chore: replace manual SQL migrations with node-pg-migrate
SonarQube Analysis / sonarqube (pull_request) Successful in 2m42s
Tests / backend-unit (pull_request) Successful in 34s
Tests / backend-integration (pull_request) Successful in 50s
Tests / frontend-e2e (pull_request) Failing after 38s

This commit is contained in:
2026-08-14 10:05:09 -05:00
parent 6ca3366821
commit 7f4479605a
8 changed files with 284 additions and 75 deletions
+27
View File
@@ -0,0 +1,27 @@
const { runner } = require('node-pg-migrate');
const path = require('path');
const direction = process.argv[2] || 'up';
runner({
databaseUrl: {
host: process.env.PGHOST || 'localhost',
port: parseInt(process.env.PGPORT || '5432', 10),
user: process.env.PGUSER,
password: process.env.PGPASSWORD,
database: process.env.PGDATABASE
},
dir: path.resolve(__dirname, 'migrations'),
direction,
migrationsTable: 'pgmigrations',
count: direction === 'down' ? 1 : Infinity,
log: (msg) => console.log(msg)
})
.then((applied) => {
console.log(`Migration complete — ${applied.length} migration(s) ${direction === 'down' ? 'reverted' : 'applied'}.`);
process.exit(0);
})
.catch((err) => {
console.error('Migration failed:', err.message);
process.exit(1);
});