/**
 * Phase 8 v2 narratives (2026-05-01) — Apply v2 narratives one-shot.
 *
 * Initialise AppDataSource puis appelle seedNarrativeV2Rewrite qui
 * réécrit les missions CR_INDIC_HUGUES + H_01_REVEIL + H_02_INFIRMIERE
 * au format v2 (cards[] + multi-choix imbriqués) selon la consigne user.
 *
 * Idempotent : UPDATE systématique. Safe à re-run (overwrite à chaque fois).
 *
 * Usage prod :
 *   ssh permatheque "cd ~/mafiaz.world/backend && npm run seed:narrative-v2"
 *
 * Usage local :
 *   npm run seed:narrative-v2:dev  (via ts-node + tunnel)
 */
import { AppDataSource } from '../config/database';
import { seedNarrativeV2Rewrite } from '../seeds/narrative-v2-rewrite.seed';

async function main(): Promise<void> {
  console.log('[SEED-V2] Initialisation AppDataSource…');
  await AppDataSource.initialize();
  try {
    console.log('[SEED-V2] Exécution seedNarrativeV2Rewrite…');
    await seedNarrativeV2Rewrite();
    console.log('[SEED-V2] Terminé avec succès.');
  } finally {
    await AppDataSource.destroy();
  }
}

main()
  .then(() => process.exit(0))
  .catch((err) => {
    console.error('[SEED-V2] Erreur fatale :', err);
    process.exit(1);
  });
