Skip to content

pgroll pull breaks migration order when migrations have explicit name fields set #850

@andrew-farries

Description

@andrew-farries

Migration file ordering is broken when pulling migrations with explicit name fields that differ from the the filename.

Description

When using explicit names in migration files, the pgroll pull command breaks the ordering of migrations.

Steps to reproduce

  1. Create migrations directory with two files:
    • 01_create_table.yml (without explicit name)
    • 02_create_another_table.yml (with explicit name: "00_oops")
  2. Run pgroll migrate migrations/ --complete to apply them
  3. Run pgroll pull tmp/

Actual behaviour

The migration from migrations/02_create_another_table.yml is pulled to tmp/00_oops, breaking the ordering as it now comes before 01_create_table.

Expected behaviour

The ordering of migrations should be preserved when pulling migrations, regardless of explicit naming.

Reproduction migrations

# 01_create_table.yml
operations:
  - create_table:
      name: customers
      columns:
        - name: id
          type: integer
          pk: true
# 02_create_another_table.yml
name: 00_oops
operations:
  - create_table:
      name: products
      columns:
        - name: id
          type: serial
          pk: true

Relates to #715

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions