// initDatabase.js - Initialize database with sample data
import sequelize from './config/config.js';
import './models/index.js';

async function initDatabase() {
  try {
    console.log('Initializing database...');
    
    // Sync database (create tables if they don't exist)
    await sequelize.sync({ force: false });
    console.log('Database tables synced successfully');
    
    // Import and run seed data
    const { default: seedData } = await import('./seedData.js');
    console.log('Database initialization completed!');
    
  } catch (error) {
    console.error('Error initializing database:', error);
  } finally {
    await sequelize.close();
  }
}

// Run the initialization
initDatabase();

