32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
|
|
import { sequelize } from '../config/database';
|
|
import { up } from '../migrations/20260123-fix-template-id-schema';
|
|
|
|
async function forceRun() {
|
|
try {
|
|
await sequelize.authenticate();
|
|
console.log('✅ Connected to DB');
|
|
|
|
const queryInterface = sequelize.getQueryInterface();
|
|
|
|
// 1. Remove from migrations table if exists (to keep track clean)
|
|
await sequelize.query("DELETE FROM migrations WHERE name = '20260123-fix-template-id-schema'");
|
|
console.log('DATA CLEANUP: Removed migration record to force re-run tracking.');
|
|
|
|
// 2. Run the migration up function directly
|
|
console.log('🚀 Running migration manually...');
|
|
await up(queryInterface);
|
|
|
|
// 3. Mark as executed
|
|
await sequelize.query("INSERT INTO migrations (name) VALUES ('20260123-fix-template-id-schema')");
|
|
console.log('✅ Migration applied and tracked successfully.');
|
|
|
|
} catch (error: any) {
|
|
console.error('❌ Error executing force migration:', error.message, error);
|
|
} finally {
|
|
await sequelize.close();
|
|
}
|
|
}
|
|
|
|
forceRun();
|