30 lines
688 B
JavaScript
30 lines
688 B
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
const { query } = require('./db');
|
|
|
|
async function runMigration() {
|
|
try {
|
|
const migrationPath = path.join(
|
|
__dirname,
|
|
'migrations',
|
|
'add_chicken_count_and_population.sql'
|
|
);
|
|
const sql = fs.readFileSync(migrationPath, 'utf8');
|
|
|
|
// Split by semicolon and execute each statement
|
|
const statements = sql.split(';').filter((stmt) => stmt.trim());
|
|
|
|
for (const statement of statements) {
|
|
if (statement.trim()) {
|
|
await query(statement);
|
|
}
|
|
}
|
|
process.exit(0);
|
|
} catch (error) {
|
|
console.error('Migration failed:', error);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
runMigration();
|