phoenixRealWorld/priv/repo/migrations/20250410151128_create_comments.exs
ReyoKatsu 6431f6651a
init
2025-04-12 00:31:08 +09:00

16 lines
418 B
Elixir

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