Final version

This commit is contained in:
cyrteL
2025-08-22 19:26:43 +03:00
committed by GitHub
parent b4c1a2caa9
commit 558cd96cdf
31 changed files with 6181 additions and 1632 deletions

26
server/scripts/migrate.js Normal file
View File

@ -0,0 +1,26 @@
import fs from 'fs';
import path from 'path';
import url from 'url';
import pool from '../src/config/db.js';
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
async function run() {
const schemaPath = path.join(__dirname, '..', 'sql', 'schema.sql');
const sql = fs.readFileSync(schemaPath, 'utf8');
const statements = sql.split(/;\s*\n/).filter(s => s.trim());
const conn = await pool.getConnection();
try {
for (const stmt of statements) {
await conn.query(stmt);
}
console.log('Migration completed');
} finally {
conn.release();
process.exit(0);
}
}
run().catch(err => { console.error(err); process.exit(1); });