import { PrismaClient } from '@prisma/client'

const prisma = new PrismaClient()

async function testDatabase() {
  try {
    console.log('Testing database connection...')

    // Test basic connection
    const versions = await prisma.bibleVersion.findMany()
    console.log('Bible versions found:', versions.length)

    for (const version of versions) {
      console.log(`Version: ${version.name} (${version.abbreviation}) - ${version.language}`)

      const books = await prisma.bibleBook.findMany({
        where: { versionId: version.id },
        take: 3
      })
      console.log(`  Books: ${books.length}`)

      for (const book of books) {
        console.log(`    - ${book.name} (order: ${book.orderNum})`)
      }
    }

  } catch (error) {
    console.error('Database test failed:', error)
  } finally {
    await prisma.$disconnect()
  }
}

testDatabase()