defmodule PhoenixRealWorld.Repo.Migrations.CreateComments do use Ecto.Migration def change do create table(:comments) do add :body, :text, null: false #← null: falseを追加 add :article_id, references(:articles, on_delete: :nothing), null: false #← null: falseを追加 timestamps(type: :utc_datetime) end create index(:comments, [:article_id]) end end