ping drizzle connection

This commit is contained in:
einhornimmond 2025-12-06 15:01:10 +01:00
parent 349fa32ede
commit 165fc3fbf1
2 changed files with 2 additions and 2 deletions

View File

@ -1,4 +1,3 @@
import { sql } from 'drizzle-orm'
import { drizzle, MySql2Database } from 'drizzle-orm/mysql2' import { drizzle, MySql2Database } from 'drizzle-orm/mysql2'
import Redis from 'ioredis' import Redis from 'ioredis'
import { getLogger } from 'log4js' import { getLogger } from 'log4js'
@ -92,6 +91,7 @@ export class AppDatabase {
database: CONFIG.DB_DATABASE, database: CONFIG.DB_DATABASE,
port: CONFIG.DB_PORT, port: CONFIG.DB_PORT,
}) })
await this.drizzleConnection.ping()
this.drizzleDataSource = drizzle({ client: this.drizzleConnection }) this.drizzleDataSource = drizzle({ client: this.drizzleConnection })
} }
// retry connection on failure some times to allow database to catch up // retry connection on failure some times to allow database to catch up

View File

@ -16,7 +16,7 @@ let db: MySql2Database
beforeAll(async () => { beforeAll(async () => {
await appDB.init() await appDB.init()
db = appDB.getDrizzleDataSource() db = appDB.getDrizzleDataSource()
// await db.delete(openaiThreadsTable) await db.delete(openaiThreadsTable)
}) })
afterAll(async () => { afterAll(async () => {
await appDB.destroy() await appDB.destroy()