Add SQLite migration foundation #42

Merged
erik merged 2 commits from feat/task-69937fe4-sqlite-migrations into main 2026-05-22 08:16:50 -05:00
Owner

Summary

  • Add SQLite connection helper with foreign keys enabled.
  • Add migration runner with schema_migrations, deterministic SQL discovery, idempotent apply, and status reporting.
  • Add db:migrate and db:status scripts for the template site.
  • Add isolated temp-database tests for migration creation, tracking, idempotence, pending status, and foreign keys.
  • Document DATABASE_PATH and the policy that feature-specific tables are added by future manually testable vertical slices.

Scope

This PR intentionally adds no feature tables. Posts/tags/auth/social/media tables should be introduced by the future vertical feature slice that implements manually testable behavior needing those tables.

Testing

  • make check
  • ./scripts/pre-pr.sh
  • Manual smoke: DATABASE_PATH=/tmp/slugkit.sqlite npm run db:migrate --workspace @slugkit/template-site and DATABASE_PATH=/tmp/slugkit.sqlite npm run db:status --workspace @slugkit/template-site

Task: #task-69937fe4

## Summary - Add SQLite connection helper with foreign keys enabled. - Add migration runner with `schema_migrations`, deterministic SQL discovery, idempotent apply, and status reporting. - Add `db:migrate` and `db:status` scripts for the template site. - Add isolated temp-database tests for migration creation, tracking, idempotence, pending status, and foreign keys. - Document `DATABASE_PATH` and the policy that feature-specific tables are added by future manually testable vertical slices. ## Scope This PR intentionally adds no feature tables. Posts/tags/auth/social/media tables should be introduced by the future vertical feature slice that implements manually testable behavior needing those tables. ## Testing - `make check` - `./scripts/pre-pr.sh` - Manual smoke: `DATABASE_PATH=/tmp/slugkit.sqlite npm run db:migrate --workspace @slugkit/template-site` and `DATABASE_PATH=/tmp/slugkit.sqlite npm run db:status --workspace @slugkit/template-site` Task: #task-69937fe4
feat: add SQLite migration foundation
All checks were successful
CI / build-lint-test (pull_request) Successful in 16m18s
a6a5fdb723
Task: #task-69937fe4
fix: use built-in Node SQLite
All checks were successful
CI / build-lint-test (pull_request) Successful in 30s
52a64d952b
Task: #task-69937fe4
Author
Owner

PR Review: Approved

Summary

Reviewed PR #42 at commit 52a64d9. The PR adds a foundation-only SQLite migration setup using Node's built-in node:sqlite, with no feature-specific tables. It includes database path configuration, foreign-key-enabled connections, migration discovery/application/status tracking via schema_migrations, template scripts for db:migrate and db:status, isolated temp-database tests, and documentation for the vertical-slice migration policy.

Acceptance Criteria

  • The migration command creates a SQLite database from scratch.
  • The migration runner records applied migrations in schema_migrations.
  • Re-running migrations is idempotent and does not reapply completed migrations.
  • A migration status/check command provides a manual verification path.
  • Test runs use isolated temporary databases and do not modify a developer database.
  • .env.example documents database configuration.
  • Documentation explains that feature-specific tables are added by future manually testable vertical slices.
  • Relevant lint/test checks pass: make check, ./scripts/pre-pr.sh, manual migrate/status smoke, and Forgejo CI all passed.

Blocking Issues

None.

Warnings

  • Node currently prints an experimental warning for node:sqlite. This is acceptable for the foundation because the project already targets Node 24 and avoiding native SQLite dependencies keeps CI fast and reliable.

Verdict

Approved for merge.

## PR Review: Approved ### Summary Reviewed PR #42 at commit `52a64d9`. The PR adds a foundation-only SQLite migration setup using Node's built-in `node:sqlite`, with no feature-specific tables. It includes database path configuration, foreign-key-enabled connections, migration discovery/application/status tracking via `schema_migrations`, template scripts for `db:migrate` and `db:status`, isolated temp-database tests, and documentation for the vertical-slice migration policy. ### Acceptance Criteria - [x] The migration command creates a SQLite database from scratch. - [x] The migration runner records applied migrations in `schema_migrations`. - [x] Re-running migrations is idempotent and does not reapply completed migrations. - [x] A migration status/check command provides a manual verification path. - [x] Test runs use isolated temporary databases and do not modify a developer database. - [x] `.env.example` documents database configuration. - [x] Documentation explains that feature-specific tables are added by future manually testable vertical slices. - [x] Relevant lint/test checks pass: `make check`, `./scripts/pre-pr.sh`, manual migrate/status smoke, and Forgejo CI all passed. ### Blocking Issues None. ### Warnings - Node currently prints an experimental warning for `node:sqlite`. This is acceptable for the foundation because the project already targets Node 24 and avoiding native SQLite dependencies keeps CI fast and reliable. ### Verdict Approved for merge.
erik merged commit 409693e3cd into main 2026-05-22 08:16:50 -05:00
Sign in to join this conversation.
No description provided.