Adds url_slug field for custom page URLs: - Migration with unique partial index on non-null slugs - Page schema with validation (format, uniqueness, reserved words) - effective_url/1 helper to resolve custom or default slug - Default page configs updated with url_slug field Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
13 lines
293 B
Elixir
13 lines
293 B
Elixir
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
|