Skip to content

fix: detect and re-run migration 029 when forms tables are missing#779

Merged
lane711 merged 1 commit intomainfrom
lane711/fix-issue-762
Apr 9, 2026
Merged

fix: detect and re-run migration 029 when forms tables are missing#779
lane711 merged 1 commit intomainfrom
lane711/fix-issue-762

Conversation

@lane711
Copy link
Copy Markdown
Collaborator

@lane711 lane711 commented Apr 9, 2026

Summary

  • Fixes Migration ID 029 reused across versions causes cascading failures on upgrade #762: Migration ID 029 was reassigned from "Ai Search Plugin" to "Add Forms System" between releases. Users upgrading from older versions had 029 marked as applied for the wrong migration, causing forms tables to never be created and cascading failures for migrations 030 and 033.
  • Adds bidirectional auto-detection for migration 029 in autoDetectAppliedMigrations(): if 029 is recorded but forms/form_submissions/form_files tables don't exist, the stale record is removed so the forms migration re-runs on next bootstrap.
  • Improves admin API error messaging to include per-migration failure details instead of a generic "Failed to run migrations".

Changes

File Description
packages/core/src/services/migrations.ts Add 029 auto-detection (same pattern as existing 011 check); add errors array to runPendingMigrations() return type
packages/core/src/routes/admin-api.ts Pass through per-migration errors in POST /migrations/run response
packages/core/src/services/migrations.test.ts 7 unit tests covering all detection scenarios
docs/ai/plans/fix-762-migration-029-reuse-plan.md Implementation plan

Testing

  • Unit tests pass locally (1443 tests, 0 failures)
  • TypeScript compiles with no errors
  • New tests cover all 4 detection scenarios for migration 029

Test plan

  • Verify on a fresh D1 database that all migrations apply correctly
  • Verify on an upgraded database (with old 029 = Ai Search) that forms migration re-runs
  • Verify admin UI shows specific migration errors instead of generic message

🤖 Generated with Claude Code

)

Migration ID 029 was reassigned from "Ai Search Plugin" to "Add Forms
System" between releases. Users upgrading from older versions had 029
marked as applied for the wrong migration, causing forms tables to never
be created and cascading failures for migrations 030 and 033.

- Add bidirectional auto-detection for migration 029 in
  autoDetectAppliedMigrations(): if 029 is recorded but forms tables
  don't exist, remove the stale record so it re-runs
- Include per-migration error details in admin API response instead of
  generic "Failed to run migrations"
- Add unit tests for all four detection scenarios

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lane711 lane711 merged commit 320a4da into main Apr 9, 2026
2 checks passed
@lane711 lane711 deleted the lane711/fix-issue-762 branch April 9, 2026 23:11
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.

Migration ID 029 reused across versions causes cascading failures on upgrade

1 participant