#!/usr/bin/env ts-node /** * Script to verify Prisma client is up to date with schema * Run this to check if externalEventId field is available in Prisma client */ import { PrismaClient } from '@prisma/client'; const prisma = new PrismaClient(); async function verifyPrismaClient() { try { console.log('Checking if externalEventId field is available in Prisma client...\n'); // Try to access the externalEventId field in the Event model // If it doesn't exist, TypeScript/Prisma will throw an error at compile time // But we can check at runtime by trying to query with it // Check if we can select externalEventId try { const testEvent = await prisma.event.findFirst({ select: { id: true, title: true, externalEventId: true, externalEventUrl: true, }, }); if (testEvent !== null) { console.log('āœ… Prisma client recognizes externalEventId and externalEventUrl fields'); console.log(' Sample event:', { id: testEvent.id, title: testEvent.title, hasExternalEventId: 'externalEventId' in testEvent, hasExternalEventUrl: 'externalEventUrl' in testEvent, }); } else { console.log('āš ļø No events found, but Prisma client seems to recognize the fields'); } } catch (error: any) { if (error.message?.includes('externalEventId') || error.message?.includes('Unknown argument')) { console.error('āŒ Prisma client does NOT recognize externalEventId field'); console.error(' Error:', error.message); console.log('\nšŸ”§ Solution:'); console.log(' 1. Run: npx prisma generate'); console.log(' 2. Restart your Next.js server'); } else { throw error; } } // Also check database directly const dbColumns = await prisma.$queryRaw>` SELECT column_name, data_type FROM information_schema.columns WHERE table_name = 'Event' AND column_name IN ('externalEventId', 'externalEventUrl') `; console.log('\nšŸ“Š Database columns:'); if (dbColumns.length === 0) { console.log(' āŒ externalEventId and externalEventUrl columns NOT found in database'); console.log(' šŸ”§ Run the migration: npx prisma migrate deploy'); } else { console.log(' āœ… Database columns exist:'); dbColumns.forEach(col => { console.log(` - ${col.column_name} (${col.data_type})`); }); } await prisma.$disconnect(); } catch (error) { console.error('Error:', error); await prisma.$disconnect(); process.exit(1); } } verifyPrismaClient();