update context API
All checks were successful
Deploy to Production / deploy (push) Successful in 19s

This commit is contained in:
silverpro89
2026-02-06 11:28:06 +07:00
parent 97dbbd4d12
commit aaba22b40c
12 changed files with 1375 additions and 49 deletions

45
sync-context-alter.js Normal file
View File

@@ -0,0 +1,45 @@
/**
* Sync Context model to database with ALTER
* This will update the existing table structure
*/
const { sequelize } = require('./config/database');
const Context = require('./models/Context');
async function syncContext() {
try {
console.log('🔄 Starting Context table sync with ALTER...');
// Test connection
await sequelize.authenticate();
console.log('✅ Database connection OK');
// Sync Context model with alter to update structure
await Context.sync({ alter: true });
console.log('✅ Context table synced successfully (grade column updated to INTEGER)');
// Show table structure
const [columns] = await sequelize.query(`
SELECT COLUMN_NAME, COLUMN_TYPE, IS_NULLABLE, COLUMN_DEFAULT, COLUMN_COMMENT
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'context' AND TABLE_SCHEMA = DATABASE()
ORDER BY ORDINAL_POSITION
`);
console.log('\n📊 Context table structure:');
columns.forEach((col, index) => {
console.log(` ${index + 1}. ${col.COLUMN_NAME} - ${col.COLUMN_TYPE} ${col.IS_NULLABLE === 'NO' ? 'NOT NULL' : 'NULL'}`);
if (col.COLUMN_COMMENT) {
console.log(` Comment: ${col.COLUMN_COMMENT}`);
}
});
console.log('\n✅ Context table update complete!');
process.exit(0);
} catch (error) {
console.error('❌ Error syncing Context table:', error.message);
console.error(error.stack);
process.exit(1);
}
}
syncContext();