update context API
All checks were successful
Deploy to Production / deploy (push) Successful in 19s
All checks were successful
Deploy to Production / deploy (push) Successful in 19s
This commit is contained in:
45
sync-context-alter.js
Normal file
45
sync-context-alter.js
Normal 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();
|
||||
Reference in New Issue
Block a user