refactor(DIS-108): extract DB schema to src/db/schema.sql (SSOT) #50

Merged
dev merged 2 commits from phase-1/db-schema-ssot into main 2026-04-09 16:01:49 +00:00
Owner

Summary

  • Move all CREATE TABLE/CREATE INDEX DDL out of database.ts into src/db/schema.sql (single source of truth)
  • database.ts now loads schema.sql at startup via fs.readFileSync and applies it with db.exec(schema)
  • All statements use IF NOT EXISTS for idempotent schema initialization
  • Add tests/integration/db-init.test.ts with 3 tests: table existence, idempotency, and basic workspace CRUD

Test plan

  • npx vitest run tests/integration/db-init.test.ts � all 3 tests pass
  • npx vitest run � full suite (47 tests) still green
  • TypeScript compiles without errors
## Summary - Move all `CREATE TABLE`/`CREATE INDEX` DDL out of `database.ts` into `src/db/schema.sql` (single source of truth) - `database.ts` now loads `schema.sql` at startup via `fs.readFileSync` and applies it with `db.exec(schema)` - All statements use `IF NOT EXISTS` for idempotent schema initialization - Add `tests/integration/db-init.test.ts` with 3 tests: table existence, idempotency, and basic workspace CRUD ## Test plan - [x] `npx vitest run tests/integration/db-init.test.ts` � all 3 tests pass - [x] `npx vitest run` � full suite (47 tests) still green - [x] TypeScript compiles without errors
dev added 1 commit 2026-04-09 15:50:29 +00:00
refactor(DIS-108): extract DB schema to src/db/schema.sql (SSOT)
Some checks failed
CI / build-and-test (ubuntu-latest) (pull_request) Has been cancelled
CI / build-and-test (windows-latest) (pull_request) Has been cancelled
CI / lint (pull_request) Has been cancelled
3dd75ddc30
Move all CREATE TABLE/INDEX DDL from database.ts to schema.sql.
database.ts loads and executes schema.sql via db.exec().
Add integration test verifying idempotent schema init.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
dev added 1 commit 2026-04-09 16:01:15 +00:00
fix(DIS-108): copy schema.sql to dist/ after tsc build
Some checks failed
CI / build-and-test (ubuntu-latest) (pull_request) Has been cancelled
CI / build-and-test (windows-latest) (pull_request) Has been cancelled
CI / lint (pull_request) Has been cancelled
aeb4bd5b59
TypeScript does not copy non-.ts files. Add a cpSync step to the
build and dev scripts so dist/db/schema.sql exists at runtime.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
dev merged commit 67433d63fa into main 2026-04-09 16:01:49 +00:00
dev deleted branch phase-1/db-schema-ssot 2026-04-10 08:24:39 +00:00
Sign in to join this conversation.
No description provided.