brajnacs

brajnacs

Ecto Migration Can't be executed, Migration name is duplicated

Hi Everyone,

I am using Phoenix for a game application and while everything works great I am stuck with this one issue with Ecto migrations.

When running migrations no matter if the database is empty or not, it throws the following error.

(Ecto.MigrationError) migrations can’t be executed, migration name create_users is duplicated (ecto_sql) lib/ecto/migrator.ex:572: Ecto.Migrator.ensure_no_duplication!/1 (ecto_sql) lib/ecto/migrator.ex:414: Ecto.Migrator.run/4 (ecto_sql) lib/ecto/migrator.ex:142: Ecto.Migrator.with_repo/3 (game_of_fortune) lib/game_of_fortune/release.ex:10: anonymous fn/2 in GameOfFortune.Release.migrate/0 (elixir) lib/enum.ex:1948: Enum.“-reduce/3-lists^foldl/2-0-”/3 (game_of_fortune) lib/game_of_fortune/release.ex:9: GameOfFortune.Release.migrate/0 (stdlib) erl_eval.erl:680: :erl_eval.do_apply/6 Build step ‘Execute shell’ marked build as failure Finished: FAILURE

I am running the migration from the release as defined in Phoenix deployment documentation.

I tried doing the same on my MacBook and it just works fine. There are no duplicate migrations in code. Its not working on ubuntu machine. I am building the release in a docker image.

PS - The local version of Postgres on Macbook is 11.5, while on the Ubuntu server its 9.5.19

Marked As Solved

brajnacs

brajnacs

Thanks for your help,

This turned out to be a completely different problem. After building release in a container, our devops team rsync that to a different server and they ran rsync in incremental mode, so an old file was a leftover from a previous rsync.

Thank you very much for helping me out.

Also Liked

wolfiton

wolfiton

Doesn’t pow create a migration on it’s own, when you run mix pow.install?

Confirmed it from the pow docs

Excerpt from the docs

mix pow.install

This will add the following files to your app:

LIB_PATH/users/user.ex
**PRIV_PATH/repo/migrations/TIMESTAMP_create_user.ex**

It will generate a migration: PRIV_PATH/repo/migrations/TIMESTAMP_create_user.ex so here is your duplicate in your migration.

I hope that your problem is solved now.

hauleth

hauleth

Could you provide list of all migrations? ls -1 priv/repo/

Last Post!

Kenneth_e

Kenneth_e

In Ecto migration, tables are added to DB from migration using timestamps as counters. In every Elixir migration file, you will see a DateTime string at the beginning of the name like this:

20230216222425_create_users.exs

Guessing with your error which I experienced myself, you modified the DateTime manually. Go through your migrations files again.

Where Next?

Popular in Questions Top

New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

Other popular topics Top

KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36820 110
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

We're in Beta

About us Mission Statement