Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to run Ecto migrations in Elixir/Phoenix from an `iex -S mix` or production console
# How to run Ecto migrations from IEx console... Examples
# preliminaries assumed in the following code, change to fit your environment:
alias YourAppName.Repo
your_app_name_as_atom = :mpnetwork
downto_version = 20170724182558
# Down:
Ecto.Migrator.run(Repo, "priv/repo/migrations/", :down, [to: downto_version])
# Up:
Ecto.Migrator.run(Repo, "priv/repo/migrations/", :up, [all: true])
# In production when not sure if working directory is inside app dir:
Ecto.Migrator.run(Repo, Application.app_dir(your_app_name_as_atom, "priv/repo/migrations"), :down, [to: downto_version])
Ecto.Migrator.run(Repo, Application.app_dir(your_app_name_as_atom, "priv/repo/migrations"), :up, [all: true])
@astavonintsc

This comment has been minimized.

Copy link

astavonintsc commented Mar 3, 2020

is there a way to run mix ecto.create from console?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.