DRYな備忘録

Don't Repeat Yourself.

Ecto.Migration内でINSERTする

Ecto.Migration – Ecto v2.0.0-beta.0

execute使お...

defmodule MyApp.Repo.Migrations.CreateProviderTable do
  use Ecto.Migration

  def change do
    create table(:providers) do
      add :name, :string

      timestamps
    end
    create unique_index(:providers, [:name])

    # Ensure standard rows
    execute "INSERT INTO providers (id, name) VALUES (1, 'github')"

  end
end

DRYな備忘録