Skip to content

db pull suggests contradictory repairs for mixed-width migration versions #7775

Done

Description

@jonxsong

Affected area

Migrations

Supabase CLI version

3.4.0-beta.5

Operating system

Windows 11 x64, build 26200

Installation method

Official GitHub release binary (windows_amd64)

Command

supabase.exe migration list --remote="<disposable-loopback-db-url>"
supabase.exe db pull --remote="<disposable-loopback-db-url>"

Actual output

migration list prints 20260420 on two separate rows, once local-only and once remote-only. db pull exits 1 and prints the following after the target line:

The remote database's migration history does not match local files in supabase/migrations directory.

Make sure your local git repo is up-to-date. If the error persists, try repairing the migration history table:
supabase migration repair --status reverted 20260420 --remote=<db-url>
supabase migration repair --status applied 20260101000000 --remote=<db-url>
supabase migration repair --status applied 20260420 --remote=<db-url>

Expected behavior

20260420 and 20260420010000 should each appear as one matched row. Only 20260101000000 is missing from the database ledger. db pull should identify that mismatch and omit repair advice for the two versions already present on both sides.

Steps to reproduce

  1. In a disposable directory, create supabase/config.toml containing project_id = "migration-merge-probe". Under supabase/migrations/, create these three files, each with select 1; as its contents:

    20260101000000_example.sql
    20260420_example.sql
    20260420010000_example.sql
    
  2. In a disposable PostgreSQL database reachable over loopback, create the migration ledger:

    CREATE SCHEMA supabase_migrations;
    CREATE TABLE supabase_migrations.schema_migrations (
      version text PRIMARY KEY,
      name text,
      statements text[]
    );
    INSERT INTO supabase_migrations.schema_migrations (version)
      VALUES ('20260420'), ('20260420010000');
  3. From the fixture directory, run the commands above with the disposable database URL. The reported db pull failure occurs during migration history reconciliation, before schema diffing.

Additional context

Reproduced during AI-assisted triage with the official Windows release binary and PGlite 0.6.0 over a local PostgreSQL socket. Removing only the January file makes migration list show both shared versions correctly. With the original three-file fixture, db push --dry-run correctly identifies only the January migration as unapplied. The fixture ledger was unchanged after these commands.

The same comparison behavior is present at develop commit 17e8cbf410d07826e73c484390af7c3547dc4fb7. The inputs are ordered by text version, but the two merge loops compare parsed integers. After consuming the extra January file, a loop can advance past the remote 20260420 row before it reaches the identical local version. History reconciliation · Migration list

Related to #6036 and #6225. That fix aligned filename and version sort order. This fixture adds one genuinely local-only migration and exposes the remaining mismatch between the sort and comparison rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions