Add rollback migrations for Rebased

Signed-off-by: mkljczk <git@mkljczk.pl>
This commit is contained in:
mkljczk 2024-12-30 23:12:12 +01:00 • committed by Lain Soykaf
commit 253bbb80f5
No known key found for this signature in database
9 changed files with 133 additions and 0 deletions

View file

@ -0,0 +1,14 @@
# Adapted from Rebased
# https://gitlab.com/soapbox-pub/rebased/-/blob/main/priv/repo/migrations/20210612185407_add_email_list_field_to_users.exs
defmodule Pleroma.Repo.Migrations.AddEmailListFieldToUsers do
use Ecto.Migration
def up, do: :noop
def down do
alter table(:users) do
remove_if_exists(:accepts_email_list, :boolean)
end
end
end

View file

@ -0,0 +1,13 @@
defmodule Pleroma.Repo.Migrations.AddActivityAssignedAccountIndex do
use Ecto.Migration
def up, do: :noop
def down do
drop_if_exists(
index(:activities, ["(data->>'assigned_account')"],
name: :activities_assigned_account_index
)
)
end
end

View file

@ -0,0 +1,11 @@
defmodule Pleroma.Repo.Migrations.AddLocationToUsers do
use Ecto.Migration
def up, do: :noop
def down do
alter table(:users) do
remove_if_exists(:location, :string)
end
end
end

View file

@ -0,0 +1,10 @@
defmodule Pleroma.Repo.Migrations.CreateWebhooks do
use Ecto.Migration
def up, do: :noop
def down do
drop_if_exists(unique_index(:webhooks, [:url]))
drop_if_exists(table(:webhooks))
end
end

View file

@ -0,0 +1,45 @@
defmodule Pleroma.Repo.Migrations.AddPleromaParticipationAcceptedToNotificationsEnum do
use Ecto.Migration
def up, do: :noop
def down do
alter table(:notifications) do
modify(:type, :string)
end
"""
delete from notifications where type in ('pleroma:participation_accepted', 'pleroma:participation_request', 'pleroma:event_reminder', 'pleroma:event_update')
"""
|> execute()
"""
drop type if exists notification_type
"""
|> execute()
"""
create type notification_type as enum (
'follow',
'follow_request',
'mention',
'move',
'pleroma:emoji_reaction',
'pleroma:chat_mention',
'reblog',
'favourite',
'pleroma:report',
'poll',
'status',
'update'
)
"""
|> execute()
"""
alter table notifications
alter column type type notification_type using (type::notification_type)
"""
|> execute()
end
end

View file

@ -0,0 +1,11 @@
defmodule Pleroma.Repo.Migrations.AddLastMoveAtToUsers do
use Ecto.Migration
def up, do: :noop
def down do
alter table(:users) do
remove_if_exists(:last_move_at, :naive_datetime)
end
end
end

View file

@ -0,0 +1,11 @@
defmodule Pleroma.Repo.Migrations.AddInternalToWebhooks do
use Ecto.Migration
def up, do: :noop
def down do
alter table(:webhooks) do
remove_if_exists(:internal, :boolean)
end
end
end

View file

@ -0,0 +1,17 @@
# Adapted from Rebased
# https://gitlab.com/soapbox-pub/rebased/-/blob/main/priv/repo/migrations/20221207235104_add_events_index.exs
defmodule Pleroma.Repo.Migrations.AddEventsIndex do
use Ecto.Migration
def up, do: :noop
def down do
drop_if_exists(
index(:objects, ["(data->>'type')"],
where: "data->>'type' = 'Event'",
name: :objects_events
)
)
end
end