()
| 12 | let migrationPromise: Promise<void> | undefined; |
| 13 | |
| 14 | export function getPostgresPool(): PgPool { |
| 15 | if (!config.database.url) { |
| 16 | throw new Error('Postgres state store requires DATABASE_URL.'); |
| 17 | } |
| 18 | if (!pool) { |
| 19 | pool = new Pool({ |
| 20 | connectionString: config.database.url, |
| 21 | ssl: config.database.ssl |
| 22 | ? { |
| 23 | rejectUnauthorized: config.database.sslRejectUnauthorized, |
| 24 | } |
| 25 | : undefined, |
| 26 | }); |
| 27 | } |
| 28 | return pool; |
| 29 | } |
| 30 | |
| 31 | export async function ensurePostgresSchema(client: SqlQueryable = getPostgresPool()): Promise<void> { |
| 32 | if (client === pool && migrationPromise) return migrationPromise; |
no outgoing calls
no test coverage detected