32 lines
689 B
JavaScript
32 lines
689 B
JavaScript
|
|
const { sequelize } = require('../src/models');
|
||
|
|
|
||
|
|
async function up() {
|
||
|
|
try {
|
||
|
|
console.log('🔄 Creating database tables...');
|
||
|
|
|
||
|
|
// Sync all models (create tables)
|
||
|
|
await sequelize.sync({ force: false });
|
||
|
|
|
||
|
|
console.log('✅ All tables created successfully!');
|
||
|
|
} catch (error) {
|
||
|
|
console.error('❌ Error creating tables:', error);
|
||
|
|
throw error;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
async function down() {
|
||
|
|
try {
|
||
|
|
console.log('🔄 Dropping all tables...');
|
||
|
|
|
||
|
|
await sequelize.drop();
|
||
|
|
|
||
|
|
console.log('✅ All tables dropped successfully!');
|
||
|
|
} catch (error) {
|
||
|
|
console.error('❌ Error dropping tables:', error);
|
||
|
|
throw error;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
module.exports = { up, down };
|
||
|
|
|