#!/usr/bin/env tsx import { config } from 'dotenv'; import { Pool } from 'pg'; import { PrismaPg } from '@prisma/adapter-pg'; import { PrismaClient } from '@prisma/client'; // Load environment variables config({ path: '.env.local' }); config({ path: '.env' }); async function main() { const connectionString = process.env.DATABASE_URL || ''; console.log('DATABASE_URL:', connectionString.replace(/:[^:@]+@/, ':****@')); const pool = new Pool({ connectionString }); const adapter = new PrismaPg(pool); const prisma = new PrismaClient({ adapter }); console.log('PrismaClient created:', !!prisma); console.log('prisma.churches:', !!prisma.churches); await prisma.$connect(); const count = await prisma.churches.count({ where: { country: 'PL' } }); console.log(`Poland churches in Neon: ${count}`); const withSchedules = await prisma.churches.count({ where: { country: 'PL', massSchedules: { some: {} } } }); console.log(`With mass schedules: ${withSchedules}`); // Sample a few churches const sample = await prisma.churches.findMany({ where: { country: 'PL' }, include: { massSchedules: true }, take: 3 }); console.log('\nSample churches:'); for (const church of sample) { console.log(` - ${church.name} (${church.city}): ${church.massSchedules.length} schedules`); } await prisma.$disconnect(); await pool.end(); } main().catch(console.error);