Stage 2: DB client factory + live integration tests (real Postgres)

- packages/schema/src/client.ts: createDb(url) -> { db, sql } drizzle/postgres-js
  factory. Exposed as the ./client subpath export so the node-only driver never
  leaks into client bundles.
- packages/schema/src/db.integration.test.ts: 6 tests gated behind INTEGRATION=1
  (content insert/read, vault_path UNIQUE, idempotency_key UNIQUE no-double-post,
  content_id FK, audit append, kill-switch upsert). Verified against Postgres 17.
- Default CI suite unchanged: integration tests skip without INTEGRATION.

Closes the Stage 2.1 DoD against a live database (unblocked by Gate 0.8).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Angelo B. J. Luidens
2026-06-03 15:05:31 -04:00
parent 339801966e
commit 7543366a15
4 changed files with 172 additions and 1 deletions
+3 -1
View File
@@ -8,6 +8,7 @@
"exports": {
".": "./src/index.ts",
"./db": "./src/db.ts",
"./client": "./src/client.ts",
"./frontmatter": "./src/frontmatter.ts"
},
"scripts": {
@@ -20,7 +21,8 @@
},
"dependencies": {
"zod": "^3.23.0",
"drizzle-orm": "^0.36.0"
"drizzle-orm": "^0.36.0",
"postgres": "^3.4.5"
},
"devDependencies": {
"drizzle-kit": "^0.28.0",