[#923] Registration validations & unique index on [:user_id, :provider].
This commit is contained in:
parent
8d21859717
commit
40e9a04c31
2 changed files with 2 additions and 0 deletions
|
@ -23,6 +23,7 @@ defmodule Pleroma.Registration do
|
||||||
def changeset(registration, params \\ %{}) do
|
def changeset(registration, params \\ %{}) do
|
||||||
registration
|
registration
|
||||||
|> cast(params, [:user_id, :provider, :uid, :info])
|
|> cast(params, [:user_id, :provider, :uid, :info])
|
||||||
|
|> validate_required([:provider, :uid])
|
||||||
|> foreign_key_constraint(:user_id)
|
|> foreign_key_constraint(:user_id)
|
||||||
|> unique_constraint(:uid, name: :registrations_provider_uid_index)
|
|> unique_constraint(:uid, name: :registrations_provider_uid_index)
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,5 +12,6 @@ def change do
|
||||||
end
|
end
|
||||||
|
|
||||||
create unique_index(:registrations, [:provider, :uid])
|
create unique_index(:registrations, [:provider, :uid])
|
||||||
|
create unique_index(:registrations, [:user_id, :provider])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue