add url_slug column to pages table

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>
This commit is contained in:
jamey
2026-04-01 00:35:15 +01:00
parent 04ce28ca29
commit f56e04390c
3 changed files with 69 additions and 3 deletions

View File

@@ -0,0 +1,12 @@
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