()
| 152 | * flake-deadlocks. |
| 153 | */ |
| 154 | export const cleanDatabase = async (): Promise<void> => { |
| 155 | await db.transaction(async (tx) => { |
| 156 | await tx.execute( |
| 157 | sql`SELECT pg_advisory_xact_lock(${sql.raw( |
| 158 | String(CLEANUP_ADVISORY_LOCK_KEY) |
| 159 | )})` |
| 160 | ); |
| 161 | |
| 162 | for (const table of CLEANUP_TARGETS) { |
| 163 | await tx.execute(sql.raw(`DELETE FROM ${table}`)); |
| 164 | } |
| 165 | }); |
| 166 | }; |
| 167 | |
| 168 | /** Re-export the live `db` for convenience inside test files. */ |
| 169 | export { db }; |
no outgoing calls
no test coverage detected