Skip to content

Explicit migration names are duplicated when generation splits into multiple migrations #723

@jechol

Description

@jechol

Code of Conduct

  • I agree to follow this project's Code of Conduct

AI Policy

  • I agree to follow this project's AI Policy, or I agree that AI was not used while creating this issue.

Versions

  • Elixir: 1.19.5
  • Erlang/OTP: 28
  • ash_postgres: main
  • ash: main
  • ash_sql: main

Operating system

macOS

Current Behavior

When mix ash_postgres.generate_migrations <name> produces multiple migration files in a single run, the generated files can reuse the same explicit migration name suffix and the same migration module name.

For example, with name: "repro_case" and a split migration caused by concurrently: true, the generated files were:

  • 20260320063017_repro_case.exs
  • 20260320063018_repro_case.exs

Both files defined the same module:

  • AshPostgres.TestRepo.Migrations.ReproCase

As a result, mix ecto.migrate fails because the migration name/module is duplicated.

Reproduction

A minimal reproduction is:

  1. Define a resource with a concurrent custom index.
  2. Run:
    mix ash_postgres.generate_migrations repro_case --concurrent-indexes
  3. Observe that two migration files are generated.
  4. Inspect the generated files and note that both reuse the same explicit name suffix and the same migration module name.

In my case, the generated files were:

  • 20260320063017_repro_case.exs
  • 20260320063018_repro_case.exs

Both files defined:

  • AshPostgres.TestRepo.Migrations.ReproCase

A standalone repro project is also available here: https://github.com/jechol/ash-postgres-concurrent-indexes-repro

I also opened a repro test PR against ash_postgres here: #724

Expected Behavior

If a single generate_migrations run produces multiple migration files, each generated migration should have a unique derived file name and a unique module name, even when an explicit name is provided.

One possible approach would be to treat the provided name as a base name and append a suffix such as _1, _2, etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions