34 lines
1.5 KiB
JavaScript
34 lines
1.5 KiB
JavaScript
"use strict";
|
|
/**
|
|
* Standalone database migration CLI.
|
|
* Applies schema.sql once and exits; run via npm script from the backend package.
|
|
*/
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
require("dotenv/config");
|
|
const connection_1 = require("./connection");
|
|
/**
|
|
* Runs schema migrations and exits with code 0 on success or 1 on failure.
|
|
*/
|
|
async function migrate() {
|
|
try {
|
|
await (0, connection_1.runMigrations)();
|
|
console.log('Migrations completed successfully.');
|
|
process.exit(0);
|
|
}
|
|
catch (err) {
|
|
const code = err && typeof err === 'object' && 'code' in err ? String(err.code) : '';
|
|
if (code === 'ECONNREFUSED') {
|
|
console.error('Migration failed: cannot reach PostgreSQL (ECONNREFUSED).\n' +
|
|
' From Docker containers use host.docker.internal in DATABASE_URL, not localhost.\n' +
|
|
' Example: DATABASE_URL=postgresql://postgres:PASSWORD@host.docker.internal:5432/games_platform_db');
|
|
}
|
|
const msg = err && typeof err === 'object' && 'message' in err ? String(err.message) : '';
|
|
if (msg.includes('client password must be a string') || msg.includes('password authentication failed')) {
|
|
console.error(' Set POSTGRES_PASSWORD (and optionally DATABASE_PASSWORD) in .env — they must be passed into Docker containers.');
|
|
}
|
|
console.error('Migration failed:', err);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
migrate();
|
|
//# sourceMappingURL=migrate.js.map
|