Add PostgreSQL schema and migration runner
All tables per PRD data model with default config seeds. Migration runner tracks applied migrations in DB. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
const { Pool } = require('pg');
|
||||
const { runMigrations } = require('../../db/migrations/001_initial_schema');
|
||||
|
||||
const pool = new Pool({
|
||||
connectionString: process.env.DATABASE_URL,
|
||||
});
|
||||
|
||||
module.exports = pool;
|
||||
async function initialize() {
|
||||
await runMigrations(pool);
|
||||
}
|
||||
|
||||
module.exports = { pool, runMigrations, initialize };
|
||||
|
||||
@@ -3,6 +3,7 @@ const express = require('express');
|
||||
const cors = require('cors');
|
||||
const path = require('path');
|
||||
const healthRouter = require('./routes/health');
|
||||
const db = require('./db');
|
||||
|
||||
const app = express();
|
||||
const PORT = process.env.PORT || 3000;
|
||||
@@ -22,6 +23,9 @@ app.get('*', (req, res) => {
|
||||
res.sendFile(path.join(clientDist, 'index.html'));
|
||||
});
|
||||
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Server running on port ${PORT}`);
|
||||
});
|
||||
(async () => {
|
||||
await db.initialize();
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Server running on port ${PORT}`);
|
||||
});
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user