brajnacs

brajnacs

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

Showing Posts 1 to 6

hauleth

hauleth

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

brajnacs

brajnacs OP

I see, You are on spot. I ran the command in /app/lib//priv/repo/migrations and got the following.

20191004084419_create_users.exs
20191009104651_add_pow_email_confirmation_to_users.exs
20191013132252_create_users.exs
20191014044857_add_pow_email_confirmation_to_users.exs
20191015100022_create_card_types.exs
20191015100106_create_cards.exs
20191015102807_update_users.exs

Here clearly the migration create_users is duplicated. But how? I don’t know same release command doesn’t produce duplicate migration on my Mac

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.

brajnacs

brajnacs OP

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.

wolfiton

wolfiton

Glad that your problem is solved

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.

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
jaybe78
Hello, I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter). The diffic...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New
aseigo
ICal is a library for interacting with iCalendar data. It parses iCalendars into typed Elixir structs via ICal.from_ics, and can prepare ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews