How to Fix Supabase Migration Conflict in AI-Built Apps

Supabase migrations fail due to conflicts between local and remote states. AI-generated migration files often conflict with changes made through the Supabase Dashboard or by other team members.

Error messages you might see

Error: supabase migration repair: migration has already been applied
ERROR: relation "users" already exists

Why this happens in AI-generated code

1

Dashboard changes conflict with migrations

Schema changes made through the Supabase Dashboard aren't captured in local migration files.

2

Duplicate migration timestamps

AI generates migration files with timestamps that collide with existing migrations.

3

Divergent migration history

Different environments have applied different subsets of migrations, creating inconsistent states.

How to fix it

1

Use supabase db diff to sync

Run `supabase db diff` to capture Dashboard changes as a migration file, keeping local and remote in sync.

2

Repair migration history

Use `supabase migration repair` to mark migrations as applied or reverted in the migration history table.

3

Get professional help

Our code audit identifies this issue and provides a fix. Start at springcode.co/products for $19.

Related technologies

Can't fix it yourself?

Our code audit identifies this issue and dozens more. Get a prioritized fix list.

Security Scan

Black-box review of your public-facing app. No code access needed.

$19
  • OWASP Top 10 checks
  • SSL/TLS analysis
  • Security headers
  • Expert review within 24h
Get Started

Code Audit

In-depth review of your source code for security, quality, and best practices.

$19
  • Security vulnerabilities
  • Code quality review
  • Dependency audit
  • AI pattern analysis
Get Started
Best Value

Complete Bundle

Both scans in one package with cross-referenced findings.

$29$38
  • Everything in both products
  • Cross-referenced findings
  • Unified action plan
Get Started

100% credited toward any paid service. Start with an audit, then let us fix what we find.

Frequently asked questions

Should I make schema changes through the Dashboard or migrations?

Always use migrations for reproducibility. If you use the Dashboard, immediately run `supabase db diff` to capture the changes.

How do I reset my local Supabase database?

Run `supabase db reset` to drop and recreate the local database, applying all migrations from scratch.

Still stuck? We can fix it for you.

Send us your repo. We'll diagnose the issue and give you a fixed quote within 24 hours.

Tell Us About Your App