Skip to content

Commit

Permalink
Merge pull request #664 from naymspace/feature/properly-check-short-l…
Browse files Browse the repository at this point in the history
…inks-unique

Fix error when submitting short link with existing url suffix
  • Loading branch information
pehbehbeh authored Nov 12, 2024
2 parents e955cf4 + 6b04b85 commit c962207
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion demo/lib/demo/short_link.ex
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ defmodule Demo.ShortLink do
message: "must be URL safe (only letters, numbers, underscores, and hyphens)"
)
|> validate_length(:short_key, min: 1, max: 64)
|> unique_constraint(:short_key)
|> unique_constraint(:short_key, name: :short_links_pkey)
end

defp add_short_key(changeset) do
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
defmodule Demo.Repo.Migrations.DropShortLinksUniqueIndex do
use Ecto.Migration

def change do
drop index(:short_links, [:short_key])
end
end

0 comments on commit c962207

Please sign in to comment.