apps/docs/content/troubleshooting/new-branch-doesnt-copy-database.mdx
Branching in Supabase (Branching 2.0) relies on the current migration files in your project—not a schema dump—when creating environments from main. This means if your main branch lacks migration history, branching will not fully capture your schema. This is a known limitation highlighted in the Branching 2.0 documentation. Follow the steps below to generate, synchronize, and repair your migration history for smooth branching.
Execute the following commands to initialize and start a local project:
supabase init
supabase start
With your project linked, run:
supabase db pull --linked
This command generates a migration file in your supabase/migrations folder which reflects your remote schema. This will not run the migration locally or overwrite anything.
Upon running the above command, the Supabase CLI will typically prompt with:
Update remote migration history table? [Y/n]
Type Y to update your remote project’s migration history and ensure it matches your new local migrations.
If the CLI suggests repairing migration history due to mismatches, you might see:
Make sure your local git repo is up-to-date. If the error persists, try repairing the migration history table:
supabase migration repair --status applied TIMESTAMP_OF_MIGRATION_TO_REPAIR
Run the exact repair command provided, replacing the timestamp as instructed (example timestamp: 20251006141726). This synchronizes the migration state between local and remote.
Once your migration history is up to date, continue to use branching features as normal. Each new branch will now inherit the correct migrations from your main branch.
If further issues arise (such as schema drift or migration mismatches), review the troubleshooting documentation, and consider manual repair with supabase migration repair.