35 lines
939 B
JavaScript
35 lines
939 B
JavaScript
/**
|
|
* Script to create config table if it doesn't exist
|
|
*/
|
|
|
|
const { sequelize } = require('./src/config/database');
|
|
const Config = require('./src/models/Config');
|
|
|
|
async function createConfigTable() {
|
|
try {
|
|
console.log('Checking if config table exists...');
|
|
|
|
// Force sync the Config model (this will create the table if it doesn't exist)
|
|
await Config.sync({ force: false });
|
|
|
|
console.log('✅ Config table is ready');
|
|
|
|
// Initialize default configs
|
|
const configService = require('./src/services/configService');
|
|
await configService.initializeDefaults();
|
|
|
|
console.log('✅ Default configurations initialized');
|
|
|
|
// Test query
|
|
const configs = await Config.findAll();
|
|
console.log(`Found ${configs.length} config(s) in database`);
|
|
|
|
process.exit(0);
|
|
} catch (error) {
|
|
console.error('❌ Error:', error.message);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
createConfigTable();
|