16 lines
418 B
JavaScript
16 lines
418 B
JavaScript
import 'dotenv/config';
|
|
import fs from 'node:fs';
|
|
import { pool } from './db.js';
|
|
|
|
const sql = fs.readFileSync(new URL('./schema.sql', import.meta.url), 'utf8');
|
|
|
|
const statements = sql.split(';').map((s) => s.trim()).filter(Boolean);
|
|
|
|
for (const statement of statements) {
|
|
await pool.query(statement);
|
|
console.log('Ran:', statement.split('\n')[0], '...');
|
|
}
|
|
|
|
console.log('Migration complete.');
|
|
await pool.end();
|