21 lines
708 B
JavaScript
21 lines
708 B
JavaScript
const { pool } = require('./db');
|
|
|
|
async function migrate() {
|
|
try {
|
|
console.log('Checking endpoints table for query_params column...');
|
|
const [columns] = await pool.query(`SHOW COLUMNS FROM endpoints LIKE 'query_params'`);
|
|
if (columns.length === 0) {
|
|
console.log('Adding query_params column...');
|
|
await pool.query(`ALTER TABLE endpoints ADD COLUMN query_params JSON`);
|
|
console.log('query_params column added successfully.');
|
|
} else {
|
|
console.log('query_params column already exists.');
|
|
}
|
|
} catch (err) {
|
|
console.error('Migration failed:', err);
|
|
} finally {
|
|
process.exit();
|
|
}
|
|
}
|
|
migrate();
|