const db = require('./models');

async function syncDatabase() {
  if (process.env.NODE_ENV === 'production') {
    console.error(
      'ERROR: sync.js should not be run in production. Use migrations instead.',
    );
    process.exit(1);
  }

  try {
    console.log('Syncing database...');
    await db.sequelize.sync({ alter: true });
    console.log('Database synced successfully!');
    process.exit(0);
  } catch (error) {
    console.error('Error syncing database:', error);
    process.exit(1);
  }
}

syncDatabase();
