AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Branching Preview Migrate Step Fails On Multi-Migration Gap; --Include-All Needed

Supabase preview branch creation runs the migrate step without --include-all, causing it to fail when the branch's migration tracking table is missing a subset of the parent's migrations (gap). This produces spurious 'Service health check failed' PR comments. Using 'supabase db push --include-all --linked' applies the gap cleanly.

highConfidence 85%Supabase

Origin Analysis

The preview-branching migrate agent invokes the migration apply command (likely 'supabase db push') without the '--include-all' flag. Without this flag, the CLI does not apply migrations that are missing from the local tracking history when timestamps are out of order or when a gap exists between the branch's snapshot and the parent's migration set, leading to a failed migration step.
1. Parent project has 25 migrations tracked in supabase_migrations.schema_migrations. 2. Create a preview branch via Management API. 3. Poll /v1/projects/{preview_ref}/actions: migrate step becomes DEAD. 4. Query preview's tracking table: only 9 of 25 migrations are present. 5. Run 'supabase link --project-ref <preview_ref> && supabase db push --include-all --linked'. 6. All missing 16 migrations apply successfully; tracking table now has 25 rows.

Fixing Code Block

Edge Case Audit

Forcing --include-all may attempt to re-apply migrations already applied on the branch if the local migration directory contains entries not present in the remote tracking table but whose changes are already partially applied. Ensure all migrations are idempotent or add pre-checks to skip already applied versions. Rollback: revert the service to the previous command without --include-all; however, already applied migrations may need manual synchronization.

Ecosystem Topology