forked from AkkomaGang/akkoma
3a13f91fff
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.
19 lines
492 B
Elixir
19 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
|