pedroassumpcao/incident

Postgres init helpers generate duplicate migration version

Closed this issue · 2 comments

Bug Report Template

Postgres init helpers generate duplicate migration version

To Reproduce
Steps to reproduce the behavior:

  1. Use a clean Phoenix Project
  2. Add incident
  3. run mix incident.postgres.init -r MyApp.EventStoreRepo
  4. run mix ecto.migrate
  5. See error
ole@Oles-MBP-2 sd-party-app % mix incident.postgres.init -r SourdoughParty.EventStoreRepo
* creating priv/event_store_repo/migrations
* creating priv/event_store_repo/migrations/20210223213739_create_events_table.exs
* creating priv/event_store_repo/migrations/20210223213739_create_aggregate_locks_table.exs
ole@Oles-MBP-2 sd-party-app % mix ecto.migrate


22:37:46.210 [info]  Migrations already up
** (Ecto.MigrationError) migrations can't be executed, migration version 20210223213739 is duplicated
    (ecto_sql 3.5.4) lib/ecto/migrator.ex:605: Ecto.Migrator.ensure_no_duplication!/1
    (ecto_sql 3.5.4) lib/ecto/migrator.ex:429: Ecto.Migrator.run/4
    (ecto_sql 3.5.4) lib/ecto/migrator.ex:145: Ecto.Migrator.with_repo/3
    (ecto_sql 3.5.4) lib/mix/tasks/ecto.migrate.ex:133: anonymous fn/5 in Mix.Tasks.Ecto.Migrate.run/2
    (elixir 1.11.3) lib/enum.ex:2193: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ecto_sql 3.5.4) lib/mix/tasks/ecto.migrate.ex:121: Mix.Tasks.Ecto.Migrate.run/2
    (mix 1.11.3) lib/mix/task.ex:394: Mix.Task.run_task/3
    (mix 1.11.3) lib/mix/cli.ex:84: Mix.CLI.run_task/2
    (elixir 1.11.3) lib/code.ex:931: Code.require_file/2

Expected behavior
The migrations are executed.

@OleMchls thanks for catching this up. The issue is with the timestamp that is the same for both migration files. I will have a fix for this soon. In case you want to address locally, you can simply rename 20210223213739_create_aggregate_locks_table.exs to use another timestamp, such as 20210223213740_create_aggregate_locks_table.exs.

Pedro, thanks for getting back to quickly. I already fixgured it out, just wanted to leave the headsup