Skip to content

fix: replace migrations with final schema bootstrap - #640

Merged
krasnoperov merged 3 commits into
mainfrom
feature/final-schema-bootstrap
Aug 4, 2026
Merged

fix: replace migrations with final schema bootstrap#640
krasnoperov merged 3 commits into
mainfrom
feature/final-schema-bootstrap

Conversation

@krasnoperov

Copy link
Copy Markdown
Owner

Why

PatchRelay runs one production SQLite database that is already on the current schema. Startup compatibility migrations were still rebuilding issues through issues_new, DROP TABLE, and RENAME, which could destroy the live schema when interrupted.

What changed

  • replace all upgrade, backfill, and retired-column logic with one declarative final schema bootstrap
  • limit startup schema work to CREATE TABLE/INDEX IF NOT EXISTS
  • include every column used by current stores in fresh databases
  • remove legacy migration fixtures and add regression tests that forbid destructive DDL or data migration in the bootstrap
  • keep read-only operator preflight behavior explicit

Existing older schemas are intentionally unsupported; this deployment targets the single current production database.

Validation

  • pnpm run ci — 1024 tests, lint, typecheck, and build pass
  • focused schema/store/preflight tests pass
  • fresh schema and live production schema have identical table columns except the two operator-feed columns now correctly included in the final schema; those will be added once, offline, before the production restart
  • live PRAGMA integrity_check is ok

@review-quill review-quill Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: 🛑 Request changes — The bootstrap must be transactional so an interrupted first startup remains safely retryable.

Comment thread src/db/migrations.ts
} finally {
connection.exec("PRAGMA foreign_keys = ON");
}
connection.exec(schema);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 If a fresh install stops mid-exec, the next startup sees the first created table and refuses to resume, leaving the database incomplete. Make the bootstrap atomic.

Suggested change
connection.exec(schema);
connection.transaction(() => connection.exec(schema))();

@krasnoperov
krasnoperov merged commit 4f4bc17 into main Aug 4, 2026
2 checks passed
@krasnoperov
krasnoperov deleted the feature/final-schema-bootstrap branch August 4, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant