mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-26 21:53:06 +00:00
test: tolerate DROP DATABASE FORCE denial in migration reconciliation cleanup
This commit is contained in:
parent
df0ff76267
commit
32cc4f1c13
1 changed files with 19 additions and 3 deletions
|
|
@ -88,9 +88,25 @@ afterEach(async () => {
|
||||||
database = undefined
|
database = undefined
|
||||||
databasePool = undefined
|
databasePool = undefined
|
||||||
|
|
||||||
if (databaseName) {
|
if (!databaseName) return
|
||||||
const adminPool = new Pool({ connectionString: adminUrl })
|
|
||||||
await adminPool.query(`DROP DATABASE IF EXISTS ${quoteIdentifier(databaseName)} WITH (FORCE)`)
|
const adminPool = new Pool({ connectionString: adminUrl })
|
||||||
|
try {
|
||||||
|
// WITH (FORCE) needs rights some Cloud Postgres roles lack when another
|
||||||
|
// backend still holds the DB; fall back to a plain DROP, then warn.
|
||||||
|
try {
|
||||||
|
await adminPool.query(
|
||||||
|
`DROP DATABASE IF EXISTS ${quoteIdentifier(databaseName)} WITH (FORCE)`,
|
||||||
|
)
|
||||||
|
} catch {
|
||||||
|
await adminPool.query(`DROP DATABASE IF EXISTS ${quoteIdentifier(databaseName)}`)
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.warn(
|
||||||
|
`[campaignMigrationReconciliation] could not drop disposable DB ${databaseName}:`,
|
||||||
|
error,
|
||||||
|
)
|
||||||
|
} finally {
|
||||||
await adminPool.end()
|
await adminPool.end()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue