All checks were successful
Deploy to Production / deploy (push) Successful in 25s
Introduce Context and ContextGuide features: add Sequelize models (models/Context.js, models/ContextGuide.js), controllers (controllers/contextController.js, controllers/contextGuideController.js) and authenticated route handlers (routes/contextRoutes.js, routes/contextGuideRoutes.js). Wire the new routes into app.js and export the models from models/index.js. Refactor vocabulary: remove VocabForm, VocabMapping and VocabRelation models and relationships, update models/Vocab.js schema and indexes, and add migrate-vocab.js to drop/recreate the vocab table for the new schema. Also add a lesson editor UI (public/lesson-editor.html) and a small cleanup in models/Lesson.js.
37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
/**
|
|
* Drop and recreate Vocab table with new schema
|
|
*/
|
|
const { sequelize } = require('./config/database');
|
|
const { Vocab } = require('./models');
|
|
|
|
async function migrateVocabTable() {
|
|
try {
|
|
console.log('🔄 Starting vocab table migration...');
|
|
|
|
await sequelize.authenticate();
|
|
console.log('✅ Database connection OK');
|
|
|
|
// Drop old vocab-related tables
|
|
console.log('🗑️ Dropping old vocab-related tables...');
|
|
await sequelize.query('DROP TABLE IF EXISTS `vocab_relation`');
|
|
await sequelize.query('DROP TABLE IF EXISTS `vocab_form`');
|
|
await sequelize.query('DROP TABLE IF EXISTS `vocab_mapping`');
|
|
await sequelize.query('DROP TABLE IF EXISTS `vocab`');
|
|
console.log('✅ Old tables dropped');
|
|
|
|
// Recreate vocab table with new schema
|
|
console.log('📊 Creating new vocab table...');
|
|
await Vocab.sync({ force: true });
|
|
console.log('✅ Vocab table created with new schema');
|
|
|
|
console.log('\n✅ Vocab migration complete!');
|
|
process.exit(0);
|
|
} catch (error) {
|
|
console.error('❌ Error migrating vocab table:', error.message);
|
|
console.error(error.stack);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
migrateVocabTable();
|