tududi/backend/scripts/db-sync.js
Chris 3c1209a5a9
Express migration (#80)
* Initial migration

* Cleanup and create migration scripts

* Introduce test suite

* Fix test issues

* Correct CORS issue and update paths

* Update README
2025-06-16 21:50:44 +03:00

26 lines
No EOL
622 B
JavaScript
Executable file

#!/usr/bin/env node
/**
* Database Sync Script
* Syncs the database by creating tables if they don't exist (without dropping existing data)
*/
require('dotenv').config();
const { sequelize } = require('../models');
async function syncDatabase() {
try {
console.log('Syncing database...');
await sequelize.sync();
console.log('✅ Database synchronized successfully');
console.log('All tables have been created (existing data preserved)');
process.exit(0);
} catch (error) {
console.error('❌ Error syncing database:', error.message);
process.exit(1);
}
}
syncDatabase();