first commit

This commit is contained in:
bryan
2025-12-30 13:53:13 -06:00
commit f0e8d9400a
31 changed files with 12464 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
const fs = require('fs');
const path = require('path');
const db = require('../db');
async function initDb() {
try {
const schemaPath = path.join(__dirname, '../schema.sql');
const schemaSql = fs.readFileSync(schemaPath, 'utf8');
console.log('Applying schema...');
await db.query(schemaSql);
// Seed Channels
const channels = ['general', 'random'];
for (const name of channels) {
await db.query(
`INSERT INTO channels (name) VALUES ($1) ON CONFLICT (name) DO NOTHING`,
[name]
);
}
console.log('Channels seeded.');
console.log('Schema applied successfully.');
process.exit(0);
} catch (err) {
console.error('Error applying schema:', err);
process.exit(1);
}
}
initDb();