Bug Description
When upgrading SonicJS from a version where migration 029 was "Ai Search Plugin" to v2.12.x where 029 is now "Add Forms System", the forms migration is silently skipped because 029 is already marked as applied in the migrations table. This causes cascading failures for migrations 030 (Add Turnstile To Forms) and 033 (Form Content Integration), which depend on the forms and form_submissions tables.
Steps to Reproduce
- Run SonicJS on a version where migration
029 = "Ai Search Plugin" (applied successfully)
- Upgrade to
@sonicjs-cms/core@2.12.x where 029 = "Add Forms System"
- Go to Admin → Settings → Migrations
- Click "Run Migrations"
Expected Behavior
All pending migrations apply successfully, including the forms system tables.
Actual Behavior
- Migration
029 is skipped (already marked as applied in migrations table)
forms, form_submissions, and form_files tables are never created
- Migration
030 fails: D1_ERROR: no such table: forms: SQLITE_ERROR
- Migration
033 fails: D1_ERROR: no such table: form_submissions: SQLITE_ERROR
- Admin UI shows generic "Failed to run migrations" with no actionable detail
Root Cause
Migration ID 029 was reassigned to a completely different migration between SonicJS releases:
| Version |
Migration 029 |
Creates Tables |
| Older |
Ai Search Plugin |
ai_search related |
| 2.12.x |
Add Forms System |
forms, form_submissions, form_files |
The autoDetectAppliedMigrations() method doesn't have a detection case for 029, so it relies solely on the migrations table record — which says 029 is applied.
Workaround
Manually create the forms, form_submissions, and form_files tables via D1 SQL, then re-run migrations.
Suggestions
- Never reuse migration IDs — once a migration ID is published in a release, it should be immutable
- Add table-existence checks for migrations with dependencies — if
030 needs the forms table, verify it exists before running
- Improve error messaging in the admin UI — show which specific migrations failed and why, rather than a generic "Failed to run migrations"
- Add auto-detection for forms tables in
autoDetectAppliedMigrations() similar to how it checks for user_profiles, settings, etc.
Environment
@sonicjs-cms/core: upgraded from 2.10.0 to 2.12.1
- Runtime: Cloudflare Workers
- Database: Cloudflare D1
Bug Description
When upgrading SonicJS from a version where migration
029was "Ai Search Plugin" to v2.12.x where029is now "Add Forms System", the forms migration is silently skipped because029is already marked as applied in themigrationstable. This causes cascading failures for migrations030(Add Turnstile To Forms) and033(Form Content Integration), which depend on theformsandform_submissionstables.Steps to Reproduce
029= "Ai Search Plugin" (applied successfully)@sonicjs-cms/core@2.12.xwhere029= "Add Forms System"Expected Behavior
All pending migrations apply successfully, including the forms system tables.
Actual Behavior
029is skipped (already marked as applied inmigrationstable)forms,form_submissions, andform_filestables are never created030fails:D1_ERROR: no such table: forms: SQLITE_ERROR033fails:D1_ERROR: no such table: form_submissions: SQLITE_ERRORRoot Cause
Migration ID
029was reassigned to a completely different migration between SonicJS releases:forms,form_submissions,form_filesThe
autoDetectAppliedMigrations()method doesn't have a detection case for029, so it relies solely on themigrationstable record — which says029is applied.Workaround
Manually create the
forms,form_submissions, andform_filestables via D1 SQL, then re-run migrations.Suggestions
030needs theformstable, verify it exists before runningautoDetectAppliedMigrations()similar to how it checks foruser_profiles,settings, etc.Environment
@sonicjs-cms/core: upgraded from2.10.0to2.12.1