defmodule Berrypod.Repo.Migrations.AddUrlSlugToPages do
  use Ecto.Migration

  def change do
    alter table(:pages) do
      add :url_slug, :string
    end

    # Unique index but only for non-null values
    create unique_index(:pages, [:url_slug], where: "url_slug IS NOT NULL")
  end
end
