Skip to content
Snippets Groups Projects
Commit 40e9a04c authored by Ivan Tashkinov's avatar Ivan Tashkinov
Browse files

[#923] Registration validations & unique index on [:user_id, :provider].

parent 8d218597
Branches
No related tags found
No related merge requests found
......@@ -23,6 +23,7 @@ defmodule Pleroma.Registration do
def changeset(registration, params \\ %{}) do
registration
|> cast(params, [:user_id, :provider, :uid, :info])
|> validate_required([:provider, :uid])
|> foreign_key_constraint(:user_id)
|> unique_constraint(:uid, name: :registrations_provider_uid_index)
end
......
......@@ -12,5 +12,6 @@ defmodule Pleroma.Repo.Migrations.CreateRegistrations do
end
create unique_index(:registrations, [:provider, :uid])
create unique_index(:registrations, [:user_id, :provider])
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment