Add rollback migrations for Rebased
Signed-off-by: mkljczk <git@mkljczk.pl>
This commit is contained in:
parent
e143e645d3
commit
253bbb80f5
9 changed files with 133 additions and 0 deletions
1
changelog.d/rebased-migration.change
Normal file
1
changelog.d/rebased-migration.change
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Add optional migrations for rollback from Rebased
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue