Forked from pmarreck/migrations_in_console_cheatsheet.exs
Created
May 4, 2020 15:56
-
-
Save jclosure/863d64f2541f57c20c7d6b7e900ba44e to your computer and use it in GitHub Desktop.
How to run Ecto migrations in Elixir/Phoenix from an `iex -S mix` or production console
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment