diff --git a/priv/repo/migrations/20210416051708_remove_mastofe_settings_from_users.exs b/priv/repo/migrations/20210416051708_remove_mastofe_settings_from_users.exs index 4f6a43524..ec14a40cf 100644 --- a/priv/repo/migrations/20210416051708_remove_mastofe_settings_from_users.exs +++ b/priv/repo/migrations/20210416051708_remove_mastofe_settings_from_users.exs @@ -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 diff --git a/priv/repo/migrations/20211125110126_force_pinned_objects_to_exist.exs b/priv/repo/migrations/20211125110126_force_pinned_objects_to_exist.exs index 8749c3e13..a60c65965 100644 --- a/priv/repo/migrations/20211125110126_force_pinned_objects_to_exist.exs +++ b/priv/repo/migrations/20211125110126_force_pinned_objects_to_exist.exs @@ -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 diff --git a/priv/repo/migrations/20220116183110_add_birthday_to_users.exs b/priv/repo/migrations/20220116183110_add_birthday_to_users.exs index 46cf7947f..e92a6e303 100644 --- a/priv/repo/migrations/20220116183110_add_birthday_to_users.exs +++ b/priv/repo/migrations/20220116183110_add_birthday_to_users.exs @@ -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 @@ def change 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 diff --git a/priv/repo/migrations/20220302013920_add_language_to_users.exs b/priv/repo/migrations/20220302013920_add_language_to_users.exs index 7a63c36aa..fc5008993 100644 --- a/priv/repo/migrations/20220302013920_add_language_to_users.exs +++ b/priv/repo/migrations/20220302013920_add_language_to_users.exs @@ -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 diff --git a/priv/repo/migrations/20220616163503_add_expires_at_to_user_relationships.exs b/priv/repo/migrations/20220616163503_add_expires_at_to_user_relationships.exs index 9e117e376..42c081ce2 100644 --- a/priv/repo/migrations/20220616163503_add_expires_at_to_user_relationships.exs +++ b/priv/repo/migrations/20220616163503_add_expires_at_to_user_relationships.exs @@ -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