Force pinned_objects to be empty, not null
authorNEETzsche <neetzsche@tutanota.com>
Mon, 29 Nov 2021 18:08:09 +0000 (18:08 +0000)
committerlain <lain@soykaf.club>
Mon, 29 Nov 2021 18:08:09 +0000 (18:08 +0000)
priv/repo/migrations/20211125110126_force_pinned_objects_to_exist.exs [new file with mode: 0644]

diff --git a/priv/repo/migrations/20211125110126_force_pinned_objects_to_exist.exs b/priv/repo/migrations/20211125110126_force_pinned_objects_to_exist.exs
new file mode 100644 (file)
index 0000000..1fe9271
--- /dev/null
@@ -0,0 +1,11 @@
+defmodule Pleroma.Repo.Migrations.ForcePinnedObjectsToExist do
+  use Ecto.Migration
+
+  def change do
+    execute("UPDATE users SET pinned_objects = '{}' WHERE pinned_objects IS NULL")
+
+    alter table("users") do
+      modify(:pinned_objects, :map, null: false, default: %{})
+    end
+  end
+end