change migrations so they can be roll backed

Up to 20210416051708, which is the latest diff between akkoma and pleroma
This commit is contained in:
ilja 2023-04-15 16:33:22 +02:00
parent fd46f83d2d
commit c6d5a72002
5 changed files with 40 additions and 5 deletions

View File

@ -5,9 +5,15 @@
defmodule Pleroma.Repo.Migrations.RemoveMastofeSettingsFromUsers do
use Ecto.Migration
def change do
def up do
alter table(:users) do
remove_if_exists(:mastofe_settings, :map)
end
end
def down do
alter table(:users) do
add_if_not_exists(:mastofe_settings, :map, default: nil)
end
end
end

View File

@ -5,11 +5,19 @@
defmodule Pleroma.Repo.Migrations.ForcePinnedObjectsToExist do
use Ecto.Migration
def change do
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

View File

@ -5,7 +5,7 @@
defmodule Pleroma.Repo.Migrations.AddBirthdayToUsers do
use Ecto.Migration
def change do
def up do
alter table(:users) do
add_if_not_exists(:birthday, :date)
add_if_not_exists(:show_birthday, :boolean, default: false, null: false)
@ -13,4 +13,13 @@ defmodule Pleroma.Repo.Migrations.AddBirthdayToUsers do
create_if_not_exists(index(:users, [:show_birthday]))
end
def down do
drop_if_exists(index(:users, [:show_birthday]))
alter table(:users) do
remove_if_exists(:birthday, :date)
remove_if_exists(:show_birthday, :boolean)
end
end
end

View File

@ -1,9 +1,15 @@
defmodule Pleroma.Repo.Migrations.AddLanguageToUsers do
use Ecto.Migration
def change do
def up do
alter table(:users) do
add_if_not_exists(:language, :string)
end
end
def down do
alter table(:users) do
remove_if_exists(:language, :string)
end
end
end

View File

@ -5,9 +5,15 @@
defmodule Pleroma.Repo.Migrations.AddExpiresAtToUserRelationships do
use Ecto.Migration
def change do
def up do
alter table(:user_relationships) do
add_if_not_exists(:expires_at, :utc_datetime)
end
end
def down do
alter table(:user_relationships) do
remove_if_exists(:expires_at, :utc_datetime)
end
end
end