pleroma/priv/repo/migrations/20211125110126_force_pinned_objects_to_exist.exs
ilja 3a13f91fff Adapt some migrations so they can be rolled back
This is useful for people who want to migrate back to Pleroma.
It's also added in the docs, but also noted that this is barely tested and to be used at their own risk.
2023-06-09 22:02:26 +02:00

20 lines
492 B
Elixir

defmodule Pleroma.Repo.Migrations.ForcePinnedObjectsToExist do
use Ecto.Migration
def up 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
def down do
alter table("users") do
modify(:pinned_objects, :map, null: true, default: nil)
end
execute("UPDATE users SET pinned_objects = NULL WHERE pinned_objects = '{}'")
end
end