#!/usr/bin/env ts-node

import DatabaseMigrator from '../models/migrate';
import DatabaseSeeder from '../models/seed';
import logger from '../utils/logger';

async function setupDatabase() {
  try {
    logger.info('Starting database setup...');

    // Run migrations
    const migrator = new DatabaseMigrator();
    await migrator.migrate();

    // Seed database
    const seeder = new DatabaseSeeder();
    await seeder.seed();

    logger.info('Database setup completed successfully');
    process.exit(0);
  } catch (error) {
    logger.error('Database setup failed:', error);
    process.exit(1);
  }
}

// Run if called directly
if (require.main === module) {
  setupDatabase();
}

export default setupDatabase; 