const { PrismaClient } = require('../keep-notes/prisma/client-generated');
const prisma = new PrismaClient();

(async () => {
  console.log('=== VERIFICATION DE LA MIGRATION ===\n');

  // 1. Verifier les notebooks
  const notebooks = await prisma.notebook.findMany({ include: { labels: true } });
  console.log('Notebooks crees:', notebooks.length);
  notebooks.forEach(nb => {
    console.log(`   - ${nb.name}: ${nb.labels?.length || 0} labels`);
  });

  // 2. Verifier les labels
  const labels = await prisma.label.findMany({ where: { notebookId: { not: null } } });
  console.log(`\nLabels avec notebookId: ${labels.length}`);

  // 3. Verifier les notes
  const notesInbox = await prisma.note.count({ where: { notebookId: null } });
  const notesInNotebooks = await prisma.note.count({ where: { notebookId: { not: null } } });
  console.log(`Notes dans Inbox: ${notesInbox}`);
  console.log(`Notes dans des notebooks: ${notesInNotebooks}`);

  // 4. Total
  const totalNotes = await prisma.note.count();
  const totalLabels = await prisma.label.count();
  console.log(`\nTotaux:`);
  console.log(`   - Notes totales: ${totalNotes}`);
  console.log(`   - Labels totaux: ${totalLabels}`);

  // 5. Sample labels with their notebook
  console.log('\nSample labels:');
  const sampleLabels = await prisma.label.findMany({ take: 3, include: { notebook: true } });
  sampleLabels.forEach(l => {
    console.log(`   - ${l.name} -> ${l.notebook?.name || 'no notebook'}`);
  });

  await prisma.$disconnect();
})();
