Skip to content

chore(db): squash migrations into a single baseline - #1543

Merged
bobbyquantum merged 5 commits into
mainfrom
bobbyquantum/squash-migrations
Sep 30, 2026
Merged

bobbyquantum merged 5 commits into
mainfrom
bobbyquantum/squash-migrations

Conversation

@bobbyquantum

Copy link
Copy Markdown
Owner

Stacked on #1542. Merge that first; this PR targets its branch. It replaces the 39 incremental Drizzle migrations with a single 0000_baseline.sql generated from src/db/schema/.

Why it's safe for the preview deployment

Merging to main runs d1 migrations apply inkweld_preview. Preview was built by the old migrations and keeps its data, so the baseline uses CREATE TABLE/INDEX IF NOT EXISTS throughout. D1 sees a new file name, runs it as a no-op, and records it. No manual d1_migrations surgery is needed.

Verified against the live preview schema (read-only sqlite_master dump):

  • Applying the baseline on top of preview's schema gives 0 differences, and it runs without error.
  • A fresh baseline differs from preview in 1 cosmetic spot: user_passkeys.backed_up DEFAULT false vs 0, which SQLite stores identically.
  • A local D1 built from the old migrations with a row inserted, then upgraded with this baseline: the apply succeeds and the row is kept.
  • The same check on Bun SQLite through the Drizzle migrator: existing databases upgrade and fresh ones get all tables.

Changes

  • The schema now declares the indexes that previously existed only in hand-written migrations. Without this, fresh installs would have missed them.
    • passkey_recovery_tokens: token_hash unique index and user_id index
    • project_slug_aliases: user_id index
    • published_files: plan_id index
  • auto_review_rejections.document_id loses its length: 500 (SQLite ignores it) so it matches the existing column.
  • applySchemaPatches (startup ALTER TABLEs for columns from 0026/0030/0031) is removed, along with the two *-migration-upgrade tests.
  • Docs and wrangler.toml.example point at d1 migrations apply instead of a specific SQL file. AGENTS.md explains the baseline.

Testing

  • Backend bun test: 1,748 pass.

MCP clients now authenticate with OAuth access tokens only.

- Backend: drop the iw_proj_ key auth path, the X-API-Key header, the
  legacy MCP context type, the /api/v1/mcp-keys routes and service, the
  LEGACY_MCP_ENABLED setting and the legacyMcpEnabled feature flag. The
  permission constants move to mcp/mcp-permissions.ts. Migration 0039
  drops the mcp_access_keys table.
- MCP tools no longer accept 'xml' as an alias for 'prosemirror_xml'.
- Frontend: remove the legacy key section in project settings, the create
  key dialog, the admin toggle and their translations; regenerate the API
  client.
- E2E: the MCP suite authorizes through the OAuth flow (viewer grant for
  the read-only test); the legacy key spec is gone.
- Docs: drop the legacy API key instructions.
Replace the 39 incremental Drizzle migrations with one baseline generated
from src/db/schema. Its statements use IF NOT EXISTS, so the preview D1
(built by the old migrations) records it as a no-op on the next deploy and
fresh databases get the full schema.

- Add the indexes that only existed in hand-written migrations to the
  schema (passkey_recovery_tokens token_hash/user_id, project_slug_aliases
  user_id, published_files plan_id) so the baseline keeps them.
- Drop the length on auto_review_rejections.document_id so the column
  matches the existing TEXT column.
- Remove applySchemaPatches, which re-added migration columns at startup,
  and the two migration-upgrade tests.
- Point docs and the wrangler example at 'd1 migrations apply'.
@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Repository: bobbyquantum/inkweld/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 908fcf17-421a-4416-a0dd-313a6a256c1c


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Base automatically changed from bobbyquantum/remove-legacy-mcp-keys to main September 29, 2026 23:50
@bobbyquantum
bobbyquantum deployed to sonarcloud-analysis September 30, 2026 00:02 — with GitHub Actions Active
@sonarqubecloud

Copy link
Copy Markdown

@bobbyquantum
bobbyquantum merged commit a49deae into main Sep 30, 2026
29 checks passed
@bobbyquantum
bobbyquantum deleted the bobbyquantum/squash-migrations branch September 30, 2026 00:09

This branch was successfully deployed

1 active deployment
sonarcloud-analysis — ff950e10 Deployed Sep 30, 2026 by bobbyquantum via SonarCloud Code Analysis #5286
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