feat(schema): support safe SQLite column additions and guarded CREATE #8

Open
toad wants to merge 3 commits from feat/sqlite-safe-add-column into feat/sqlite-virtual-tables
Member

OpenSpec

Change: sqlite-safe-add-column (spec-driven). Proposal, design and sqlite-optional-ddl spec reviewed; 7/7 tasks complete. OpenSpec artifacts remain local because repository ignores openspec/.

Purpose and scope

  • SQLite can add compatible columns without rebuilding populated tables. Standalone SQL consumers also need explicit guarded CREATE, but managed migration must not hide schema drift.
  • Standalone table, view and index CREATE generators now accept opt-in { ifNotExists: true }; default SQL and persisted schema identity remain unchanged. Cowboy-managed CREATE stays unguarded, and untracked-object drift fails.
  • Existing canonical-metadata pure-add decision uses native ALTER TABLE ADD COLUMN, including referenced D1 parents. Constrained/default/STORED generated additions and table-option changes use permitted rebuilds; D1 checks actual incoming foreign keys, including unmanaged children, and refuses prohibited rebuilds before destructive SQL.
  • Populated Bun tests cover native ADD and fallback, migration records, restart no-ops, unchanged unique index/view/trigger, dependent rows and cascading actions. D1-style tests cover referenced-parent native ADD and unsafe fallback refusal with unchanged rows and metadata.
  • README.md and authoritative docs/plans/full-sqlite.md document guard limitations, D1 boundary, Bun/D1 SQLite version differences and native versus rebuild behavior.

Checkpoints

  • 6ab082c guarded standalone generators and drift tests.
  • 51a3713 native ADD, rebuild and D1-style refusal regressions.
  • 1063ede user documentation and authoritative guidance.
    All checkpoints pushed to feat/sqlite-safe-add-column; PR targets feat/sqlite-virtual-tables.

Verification

  • bun run check passed; no-output TypeScript checks across five projects passed.
  • bun run lint: 0 errors, 14 pre-existing warnings.
  • Focused tests: 95 passed; bun test: 129 passed, 0 failed (446 assertions).
  • openspec validate sqlite-safe-add-column --strict passed; apply progress 7/7.
  • Scoped feat/sqlite-virtual-tables...HEAD diff reviewed: only this change's six tracked files; git diff --check passed, no secrets found. Local and remote SHA match; working tree clean.
  • D1 behavior tested using Bun-backed D1-style connection; no live D1 execution claimed.
## OpenSpec Change: `sqlite-safe-add-column` (spec-driven). Proposal, design and `sqlite-optional-ddl` spec reviewed; 7/7 tasks complete. OpenSpec artifacts remain local because repository ignores `openspec/`. ## Purpose and scope - SQLite can add compatible columns without rebuilding populated tables. Standalone SQL consumers also need explicit guarded CREATE, but managed migration must not hide schema drift. - Standalone table, view and index CREATE generators now accept opt-in `{ ifNotExists: true }`; default SQL and persisted schema identity remain unchanged. Cowboy-managed CREATE stays unguarded, and untracked-object drift fails. - Existing canonical-metadata pure-add decision uses native `ALTER TABLE ADD COLUMN`, including referenced D1 parents. Constrained/default/STORED generated additions and table-option changes use permitted rebuilds; D1 checks actual incoming foreign keys, including unmanaged children, and refuses prohibited rebuilds before destructive SQL. - Populated Bun tests cover native ADD and fallback, migration records, restart no-ops, unchanged unique index/view/trigger, dependent rows and cascading actions. D1-style tests cover referenced-parent native ADD and unsafe fallback refusal with unchanged rows and metadata. - `README.md` and authoritative `docs/plans/full-sqlite.md` document guard limitations, D1 boundary, Bun/D1 SQLite version differences and native versus rebuild behavior. ## Checkpoints - `6ab082c` guarded standalone generators and drift tests. - `51a3713` native ADD, rebuild and D1-style refusal regressions. - `1063ede` user documentation and authoritative guidance. All checkpoints pushed to `feat/sqlite-safe-add-column`; PR targets `feat/sqlite-virtual-tables`. ## Verification - `bun run check` passed; no-output TypeScript checks across five projects passed. - `bun run lint`: 0 errors, 14 pre-existing warnings. - Focused tests: 95 passed; `bun test`: 129 passed, 0 failed (446 assertions). - `openspec validate sqlite-safe-add-column --strict` passed; apply progress 7/7. - Scoped `feat/sqlite-virtual-tables...HEAD` diff reviewed: only this change's six tracked files; `git diff --check` passed, no secrets found. Local and remote SHA match; working tree clean. - D1 behavior tested using Bun-backed D1-style connection; no live D1 execution claimed.
feat(schema): support optional guarded standalone CREATE
All checks were successful
Checks / checks (pull_request) Successful in 7s
Checks / release (pull_request) Has been skipped
6ab082c023
test(migration): cover native additions and rebuild boundaries
All checks were successful
Checks / checks (pull_request) Successful in 7s
Checks / release (pull_request) Has been skipped
51a3713acb
docs: explain safe ADD and standalone CREATE guards
All checks were successful
Checks / checks (pull_request) Successful in 7s
Checks / release (pull_request) Has been skipped
1063ede9d7
All checks were successful
Checks / checks (pull_request) Successful in 7s
Checks / release (pull_request) Has been skipped
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feat/sqlite-safe-add-column:feat/sqlite-safe-add-column
git switch feat/sqlite-safe-add-column

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch feat/sqlite-virtual-tables
git merge --no-ff feat/sqlite-safe-add-column
git switch feat/sqlite-safe-add-column
git rebase feat/sqlite-virtual-tables
git switch feat/sqlite-virtual-tables
git merge --ff-only feat/sqlite-safe-add-column
git switch feat/sqlite-safe-add-column
git rebase feat/sqlite-virtual-tables
git switch feat/sqlite-virtual-tables
git merge --no-ff feat/sqlite-safe-add-column
git switch feat/sqlite-virtual-tables
git merge --squash feat/sqlite-safe-add-column
git switch feat/sqlite-virtual-tables
git merge --ff-only feat/sqlite-safe-add-column
git switch feat/sqlite-virtual-tables
git merge feat/sqlite-safe-add-column
git push origin feat/sqlite-virtual-tables
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
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
sigitex/outlaw!8
No description provided.