Disallow NULLs in deliveries
This commit is contained in:
parent
8900cb68ae
commit
ac4a748fad
@ -23,6 +23,7 @@ defmodule Pleroma.Delivery do
|
|||||||
def changeset(delivery, params \\ %{}) do
|
def changeset(delivery, params \\ %{}) do
|
||||||
delivery
|
delivery
|
||||||
|> cast(params, [:user_id, :object_id])
|
|> cast(params, [:user_id, :object_id])
|
||||||
|
|> validate_required([:user_id, :object_id])
|
||||||
|> foreign_key_constraint(:object_id)
|
|> foreign_key_constraint(:object_id)
|
||||||
|> foreign_key_constraint(:user_id)
|
|> foreign_key_constraint(:user_id)
|
||||||
|> unique_constraint(:user_id, name: :deliveries_user_id_object_id_index)
|
|> unique_constraint(:user_id, name: :deliveries_user_id_object_id_index)
|
||||||
|
@ -3,8 +3,8 @@ defmodule Pleroma.Repo.Migrations.CreateDeliveries do
|
|||||||
|
|
||||||
def change do
|
def change do
|
||||||
create_if_not_exists table(:deliveries) do
|
create_if_not_exists table(:deliveries) do
|
||||||
add(:object_id, references(:objects, type: :id))
|
add(:object_id, references(:objects, type: :id), null: false)
|
||||||
add(:user_id, references(:users, type: :uuid, on_delete: :delete_all))
|
add(:user_id, references(:users, type: :uuid, on_delete: :delete_all), null: false)
|
||||||
end
|
end
|
||||||
create_if_not_exists index(:deliveries, :object_id, name: :deliveries_object_id)
|
create_if_not_exists index(:deliveries, :object_id, name: :deliveries_object_id)
|
||||||
create_if_not_exists(unique_index(:deliveries, [:user_id, :object_id]))
|
create_if_not_exists(unique_index(:deliveries, [:user_id, :object_id]))
|
||||||
|
Loading…
Reference in New Issue
Block a user