require('dotenv').config();
const { PrismaClient } = require('@prisma/client');

async function main() {
  console.log('DATABASE_URL:', process.env.DATABASE_URL);
  const p = new PrismaClient({ log: ['query', 'info', 'warn', 'error'] });
  try {
    const result = await p.$queryRawUnsafe('SELECT 1 as ok');
    console.log('Connected!', result);
  } catch (e) {
    console.error('Error code:', e.code);
    console.error('Error meta:', JSON.stringify(e.meta, null, 2));
    console.error('Message:', e.message);
  } finally {
    await p.$disconnect();
    process.exit(0);
  }
}

main();
