defmodule Wiki.Repo.Migrations.CreatePageLinks do use Ecto.Migration def change do create table(:page_links) do add :from_id, references(:pages, on_delete: :delete_all), primary_key: true add :to_id, references(:pages, on_delete: :delete_all), primary_key: true end create index(:page_links, [:from_id]) create index(:page_links, [:to_id]) create unique_index(:page_links, [:from_id, :to_id], name: :page_link_from_id_to_id_unique_index ) end end