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