import {SQL} from 'bun'
import {drizzle} from 'drizzle-orm/bun-sql'
import {migrate} from 'drizzle-orm/bun-sql/migrator'

import {env} from '../env'

const client = new SQL(env.DATABASE_URL)
const db = drizzle({client})

try {
  await migrate(db, {migrationsFolder: './drizzle'})
  console.log('migrations applied')
} finally {
  await client.end()
}
