(callback: (client: PoolClient) => Promise<T>)
| 36 | } |
| 37 | |
| 38 | export async function withPostgresTransaction<T>(callback: (client: PoolClient) => Promise<T>): Promise<T> { |
| 39 | const client = await getPostgresPool().connect(); |
| 40 | try { |
| 41 | await ensurePostgresSchema(); |
| 42 | await client.query('BEGIN'); |
| 43 | const result = await callback(client); |
| 44 | await client.query('COMMIT'); |
| 45 | return result; |
| 46 | } catch (error) { |
| 47 | await client.query('ROLLBACK'); |
| 48 | throw error; |
| 49 | } finally { |
| 50 | client.release(); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | async function runMigrations(client: SqlQueryable): Promise<void> { |
| 55 | await client.query(` |
no test coverage detected