feat: db pool + migration runner with idempotency
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
16
tests/helpers/db.js
Normal file
16
tests/helpers/db.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import { pool } from '../../lib/db/pool.js';
|
||||
|
||||
export async function resetDb() {
|
||||
await pool.query(`
|
||||
DROP SCHEMA IF EXISTS public CASCADE;
|
||||
CREATE SCHEMA public;
|
||||
CREATE EXTENSION IF NOT EXISTS pgcrypto;
|
||||
CREATE EXTENSION IF NOT EXISTS vector;
|
||||
`);
|
||||
}
|
||||
|
||||
export async function withClient(fn) {
|
||||
const client = await pool.connect();
|
||||
try { await fn(client); }
|
||||
finally { client.release(); }
|
||||
}
|
||||
Reference in New Issue
Block a user