17 lines
800 B
TypeScript
17 lines
800 B
TypeScript
import { readFile } from 'node:fs/promises';
|
|
// Import the pool only after an explicit apply flag, to avoid accidental connections in review mode.
|
|
const sql = await readFile(new URL('../migrations/20260928_asset_ai_questions.sql', import.meta.url), 'utf8');
|
|
if (!process.argv.includes('--apply')) {
|
|
console.log(sql);
|
|
console.log('Review only. To create this audit table in the configured DB, pass --apply.');
|
|
} else {
|
|
const { default: pool } = await import('../src/server/db.js');
|
|
try {
|
|
await pool.query(sql);
|
|
const [rows] = await pool.query('SELECT COUNT(*) AS columns_count FROM information_schema.columns WHERE table_schema=DATABASE() AND table_name=?', ['bi_asset_ai_questions']);
|
|
console.log('AI question audit table ready.', rows);
|
|
} finally {
|
|
await pool.end();
|
|
}
|
|
}
|