import { DataSource } from 'typeorm';
import { seedLegalPages } from './legal-pages.seed';

async function runSeed() {
  const dataSource = new DataSource({
    type: 'postgres',
    host: process.env.DATABASE_HOST || '10.0.0.207',
    port: parseInt(process.env.DATABASE_PORT || '5432'),
    username: process.env.DATABASE_USER || 'postgres',
    password: process.env.DATABASE_PASSWORD || 'a3ppq',
    database: process.env.DATABASE_NAME || 'parentflowdev',
    entities: [],
    synchronize: false,
  });

  try {
    await dataSource.initialize();
    console.log('Database connection established');

    await seedLegalPages(dataSource);

    console.log('Seed completed successfully!');
  } catch (error) {
    console.error('Error running seed:', error);
    process.exit(1);
  } finally {
    await dataSource.destroy();
  }
}

runSeed();
