Disallow NULLs in deliveries
authorrinpatch <rinpatch@sdf.org>
Fri, 13 Sep 2019 16:28:35 +0000 (19:28 +0300)
committerrinpatch <rinpatch@sdf.org>
Fri, 13 Sep 2019 16:28:35 +0000 (19:28 +0300)
lib/pleroma/delivery.ex
priv/repo/migrations/20190912065617_create_deliveries.exs

index 38c148c345c470025958b84c3b79667bf47f434e..29a1e5a77c7ae14b78116fa0b0433858560ca828 100644 (file)
@@ -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)
index 92ca5650a3f5e15092479af2e1d0143fb0717620..79071a79986eb75b0c925fdd3e46b589672bf130 100644 (file)
@@ -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]))