Skip to content

Commit

Permalink
fix: add slug unique constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
joaodiaslobo committed Jun 17, 2024
1 parent 443ef08 commit 4158614
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/cesium_link/redirects/redirect.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ defmodule CesiumLink.Redirects.Redirect do
|> validate_format(:slug, ~r{^[a-z0-9-]+$},
message: "must contain only lowercase letters, numbers, and hyphens"
)
|> unique_constraint(:slug, message: "already in use")
end
end
2 changes: 2 additions & 0 deletions priv/repo/migrations/20240418190329_create_redirects.exs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ defmodule CesiumLink.Repo.Migrations.CreateRedirects do

timestamps(type: :utc_datetime)
end

create unique_index(:redirects, [:slug])
end
end

0 comments on commit 4158614

Please sign in to comment.