Change drizzle connection string at runtime

I have an existing drizzle instance that's exported from a module that many other modules import. I'd like to modify that instance at runtime to change the connection string. I thought maybe I could set the $client like so:
db.$client = new Pool({
connectionString: createConnectionString({
user: inject('DATABASE_USER'),
password: inject('DATABASE_PASSWORD'),
host: inject('DATABASE_HOST'),
port: inject('DATABASE_PORT'),
database: databaseName,
})
})

await db.$client.connect()
db.$client = new Pool({
connectionString: createConnectionString({
user: inject('DATABASE_USER'),
password: inject('DATABASE_PASSWORD'),
host: inject('DATABASE_HOST'),
port: inject('DATABASE_PORT'),
database: databaseName,
})
})

await db.$client.connect()
But it just hangs.. I know this seems odd but I need to be able to swap out the db connection for each integration test.. I don't know how to accomplish that without actually modifying the singleton db connection
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server