DEV Community

loading...

TIL: Hidden switch of ecto_sql migration

Sushant Bajracharya
My key strengths: Discipline and Focus
・1 min read

There is a hidden switch --change for mix ecto.gen.migration.

mix ecto.gen.migration --change "create table(:user)"

The above code simply substitutes the value inside the def change function.

# excerpt from ecto_sql

  embed_template :migration, """
  defmodule <%= inspect @mod %> do
    use <%= inspect migration_module() %>

    def change do
  <%= @change %>
    end
  end
  """

Discussion (0)