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:
50
add-knowledge-column.js
Normal file
50
add-knowledge-column.js
Normal file
@@ -0,0 +1,50 @@
|
||||
const {sequelize} = require('./config/database');
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await sequelize.authenticate();
|
||||
console.log('✅ Database connected');
|
||||
|
||||
// Check current columns
|
||||
const [cols] = await sequelize.query('DESCRIBE context');
|
||||
console.log('\n📋 Current columns:');
|
||||
cols.forEach(c => console.log(` - ${c.Field}`));
|
||||
|
||||
const columnNames = cols.map(c => c.Field);
|
||||
|
||||
// Add knowledge column if not exists
|
||||
if (!columnNames.includes('knowledge')) {
|
||||
await sequelize.query(`
|
||||
ALTER TABLE context
|
||||
ADD COLUMN knowledge TEXT NULL
|
||||
COMMENT 'Additional knowledge or information'
|
||||
`);
|
||||
console.log('\n✅ Added knowledge column');
|
||||
} else {
|
||||
console.log('\n✅ knowledge column already exists');
|
||||
}
|
||||
|
||||
// Add status column if not exists
|
||||
if (!columnNames.includes('status')) {
|
||||
await sequelize.query(`
|
||||
ALTER TABLE context
|
||||
ADD COLUMN status INT DEFAULT 0
|
||||
COMMENT '0: Draft, 1: Enriched, 2: Prompt_Ready, 3: Generating, 4: Image_Ready, 5: Approved'
|
||||
`);
|
||||
console.log('✅ Added status column');
|
||||
} else {
|
||||
console.log('✅ status column already exists');
|
||||
}
|
||||
|
||||
// Show final structure
|
||||
const [finalCols] = await sequelize.query('DESCRIBE context');
|
||||
console.log('\n📊 Final Context table structure:');
|
||||
finalCols.forEach((c, i) => console.log(` ${i+1}. ${c.Field} (${c.Type})`));
|
||||
|
||||
process.exit(0);
|
||||
} catch (error) {
|
||||
console.error('❌ Error:', error.message);
|
||||
console.error(error.stack);
|
||||
process.exit(1);
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user