Run migrations on server startup
This commit is contained in:
@@ -8,6 +8,7 @@ import { apiRouter } from './routes/index.js';
|
||||
import { platformStatusRouter } from './routes/health.js';
|
||||
import { errorHandler } from './http/errors.js';
|
||||
import { getPool } from './db/pool.js';
|
||||
import { runMigrations } from './db/migrate.js';
|
||||
|
||||
const app = express();
|
||||
const frontendDist = path.resolve(process.cwd(), 'frontend', 'dist');
|
||||
@@ -45,6 +46,12 @@ app.get('*', (_req, res) => {
|
||||
|
||||
app.use(errorHandler);
|
||||
|
||||
app.listen(env.port, () => {
|
||||
console.log(`ACS Node app listening on port ${env.port}`);
|
||||
});
|
||||
try {
|
||||
await runMigrations();
|
||||
app.listen(env.port, () => {
|
||||
console.log(`ACS Node app listening on port ${env.port}`);
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('ACS startup failed', error);
|
||||
process.exitCode = 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user