const { prisma } = require('../src/models');
async function main() {
  // Direct write test
  const r = await prisma.aiCallLog.create({
    data: { callType: 'check_table', provider: 'test', model: 'test', textLen: 1, success: true }
  });
  console.log('✅ Direct write: id=' + r.id);
  
  const count = await prisma.aiCallLog.count();
  console.log('Total count: ' + count);
  
  const recent = await prisma.aiCallLog.findMany({ orderBy: { id: 'desc' }, take: 5 });
  for (const l of recent) console.log('  #' + l.id + ' ' + l.callType + ' ' + l.provider + ' ' + (l.success ? 'OK' : 'FAIL'));
  
  // Clean test record
  await prisma.aiCallLog.delete({ where: { id: r.id } });
  await prisma.$disconnect();
}
main().catch(e => { console.error(e.message); process.exit(1); });
