Files
eleith 3c76effc81
ci/woodpecker/push/cli Pipeline was successful
ci/woodpecker/push/core Pipeline was successful
ci/woodpecker/push/lsp Pipeline was successful
ci/woodpecker/push/web-db Pipeline was successful
ci/woodpecker/push/web-jobs Pipeline was successful
ci/woodpecker/push/web-lsp Pipeline was successful
ci/woodpecker/push/web-pieces Pipeline was successful
ci/woodpecker/push/web-worker Pipeline was successful
ci/woodpecker/push/web Pipeline was successful
[luzzle] Restructure workspace projects into apps/ and packages/ directories
2026-06-01 15:13:04 -07:00

23 lines
642 B
TypeScript

import { getDatabaseClient } from '../src/database/client.js'
import { type LuzzleDatabase } from '../src/database/tables/index.js'
import { sql } from 'kysely'
import migrate from '../src/database/migrations.js'
let cachedDb: LuzzleDatabase | null = null
export async function setupDatabase() {
if (!cachedDb) {
cachedDb = getDatabaseClient(':memory:')
const result = await migrate(cachedDb)
if (result.error) {
throw new Error(`Core migration failed: ${result.error}`)
}
}
await sql`BEGIN`.execute(cachedDb)
return cachedDb
}
export async function teardownDatabase(db: LuzzleDatabase) {
await sql`ROLLBACK`.execute(db)
}