feat: add PostgreSQL storage provider for LawNet BFF #56

Closed
dernbu wants to merge 1 commit from push-zzyrmktsoxqm into main
Owner

Summary

Implements the PostgreSQL storage provider for the LawNet BFF, adding an environment-variable-driven storage provider switch (BFF_STORAGE=filesystem|postgres).

Changes

  • Flyway V2 migration (services/flyway/sql/V2__lawnet_schema.sql): 7 tables under lawnet schema — judgments, judgment_sources, corams, catchwords, artifacts, artifact_data, citations — with appropriate indexes
  • LawnetPostgresStore (postgres-store.ts): full implementation of the LawnetStore interface using pg.Pool with parameterized queries
  • Factory switch (index.ts): getLawnetStore() reads BFF_STORAGE env var; "postgres" creates a Pool from DATABASE_URL and returns LawnetPostgresStore, otherwise falls back to LawnetFileSystemStore
  • Config: added BFF_STORAGE to compose.yaml and .env.example
  • Integration tests (postgres-store.test.ts): 19 tests that self-seed fixture data from disk against a real PostgreSQL, gracefully skipped when DATABASE_URL is absent

Verification

  • tsc --noEmit — clean
  • eslint — clean
  • prettier --check — clean
  • Filesystem store tests (17 tests) continue to pass unchanged
  • PostgreSQL store tests (19 tests) pass against a real database
  • Flyway V2 migration applies cleanly and is a no-op on reapply
  • docker compose config passes

Closes #49

## Summary Implements the PostgreSQL storage provider for the LawNet BFF, adding an environment-variable-driven storage provider switch (`BFF_STORAGE=filesystem|postgres`). ## Changes - **Flyway V2 migration** (`services/flyway/sql/V2__lawnet_schema.sql`): 7 tables under `lawnet` schema — judgments, judgment_sources, corams, catchwords, artifacts, artifact_data, citations — with appropriate indexes - **LawnetPostgresStore** (`postgres-store.ts`): full implementation of the `LawnetStore` interface using `pg.Pool` with parameterized queries - **Factory switch** (`index.ts`): `getLawnetStore()` reads `BFF_STORAGE` env var; `"postgres"` creates a `Pool` from `DATABASE_URL` and returns `LawnetPostgresStore`, otherwise falls back to `LawnetFileSystemStore` - **Config**: added `BFF_STORAGE` to `compose.yaml` and `.env.example` - **Integration tests** (`postgres-store.test.ts`): 19 tests that self-seed fixture data from disk against a real PostgreSQL, gracefully skipped when `DATABASE_URL` is absent ## Verification - [x] `tsc --noEmit` — clean - [x] `eslint` — clean - [x] `prettier --check` — clean - [x] Filesystem store tests (17 tests) continue to pass unchanged - [x] PostgreSQL store tests (19 tests) pass against a real database - [x] Flyway V2 migration applies cleanly and is a no-op on reapply - [x] `docker compose config` passes Closes #49
feat: add PostgreSQL storage provider for LawNet BFF
Some checks failed
CI / merge-check (pull_request) Failing after 58s
c43d034cb5
- Add V2 Flyway migration with lawet schema (judgments, sources,
  corams, catchwords, artifacts, artifact_data, citations)
- Implement LawnetPostgresStore implementing LawnetStore interface
  using pg.Pool
- Wire BFF_STORAGE env var switch in getLawnetStore() factory
  (filesystem | postgres)
- Add BFF_STORAGE to compose.yaml and .env.example
- Add 19 PostgreSQL-backed integration tests that self-seed fixture
  data and skip when DATABASE_URL is absent

Refs: #49
dernbu force-pushed push-zzyrmktsoxqm from c43d034cb5
Some checks failed
CI / merge-check (pull_request) Failing after 58s
to 273e4677e8
Some checks failed
CI / merge-check (pull_request) Failing after 51s
2026-06-14 12:01:17 +02:00
Compare
dernbu closed this pull request 2026-06-14 12:06:30 +02:00
Some checks failed
CI / merge-check (pull_request) Failing after 51s
Required
Details

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dernbu/lawnet-scraper!56
No description provided.