summaryrefslogtreecommitdiff
path: root/priv/repo
diff options
context:
space:
mode:
Diffstat (limited to 'priv/repo')
-rw-r--r--priv/repo/migrations/20180516154905_create_user_trigram_index.exs5
-rw-r--r--priv/repo/migrations/20190118074940_fix_user_trigram_index.exs5
-rw-r--r--priv/repo/migrations/20190603173419_add_tag_index_to_objects.exs5
-rw-r--r--priv/repo/migrations/20200919182636_remoteip_plug_rename.exs4
-rw-r--r--priv/repo/migrations/20220319000000_add_status_to_notifications_enum.exs51
-rw-r--r--priv/repo/migrations/20240527144418_oban_queues_refactor.exs32
-rw-r--r--priv/repo/migrations/20240530011739_add_missing_foreign_keys.exs20
-rw-r--r--priv/repo/migrations/20240608003957_upgrade_oban_jobs_to_v12.exs7
-rw-r--r--priv/repo/migrations/20240619141319_deprecate_config_db_logger.exs7
9 files changed, 132 insertions, 4 deletions
diff --git a/priv/repo/migrations/20180516154905_create_user_trigram_index.exs b/priv/repo/migrations/20180516154905_create_user_trigram_index.exs
index 68878e1e2..049b10175 100644
--- a/priv/repo/migrations/20180516154905_create_user_trigram_index.exs
+++ b/priv/repo/migrations/20180516154905_create_user_trigram_index.exs
@@ -7,7 +7,10 @@ defmodule Pleroma.Repo.Migrations.CreateUserTrigramIndex do
def change do
create_if_not_exists(
- index(:users, ["(nickname || name) gist_trgm_ops"], name: :users_trigram_index, using: :gist)
+ index(:users, ["(nickname || name) gist_trgm_ops"],
+ name: :users_trigram_index,
+ using: :gist
+ )
)
end
end
diff --git a/priv/repo/migrations/20190118074940_fix_user_trigram_index.exs b/priv/repo/migrations/20190118074940_fix_user_trigram_index.exs
index b0f5238a0..3958ea262 100644
--- a/priv/repo/migrations/20190118074940_fix_user_trigram_index.exs
+++ b/priv/repo/migrations/20190118074940_fix_user_trigram_index.exs
@@ -20,7 +20,10 @@ defmodule Pleroma.Repo.Migrations.FixUserTrigramIndex do
drop_if_exists(index(:users, [], name: :users_trigram_index))
create_if_not_exists(
- index(:users, ["(nickname || name) gist_trgm_ops"], name: :users_trigram_index, using: :gist)
+ index(:users, ["(nickname || name) gist_trgm_ops"],
+ name: :users_trigram_index,
+ using: :gist
+ )
)
end
end
diff --git a/priv/repo/migrations/20190603173419_add_tag_index_to_objects.exs b/priv/repo/migrations/20190603173419_add_tag_index_to_objects.exs
index 00c71e95f..a3cb17f3b 100644
--- a/priv/repo/migrations/20190603173419_add_tag_index_to_objects.exs
+++ b/priv/repo/migrations/20190603173419_add_tag_index_to_objects.exs
@@ -7,7 +7,10 @@ defmodule Pleroma.Repo.Migrations.AddTagIndexToObjects do
def change do
drop_if_exists(
- index(:activities, ["(data #> '{\"object\",\"tag\"}')"], using: :gin, name: :activities_tags)
+ index(:activities, ["(data #> '{\"object\",\"tag\"}')"],
+ using: :gin,
+ name: :activities_tags
+ )
)
create_if_not_exists(index(:objects, ["(data->'tag')"], using: :gin, name: :objects_tags))
diff --git a/priv/repo/migrations/20200919182636_remoteip_plug_rename.exs b/priv/repo/migrations/20200919182636_remoteip_plug_rename.exs
index b9a8fd0e1..69627d3d8 100644
--- a/priv/repo/migrations/20200919182636_remoteip_plug_rename.exs
+++ b/priv/repo/migrations/20200919182636_remoteip_plug_rename.exs
@@ -9,7 +9,9 @@ defmodule Pleroma.Repo.Migrations.RemoteipPlugRename do
def up do
config =
- from(c in Pleroma.ConfigDB, where: c.group == ^:pleroma and c.key == ^Pleroma.Plugs.RemoteIp)
+ from(c in Pleroma.ConfigDB,
+ where: c.group == ^:pleroma and c.key == ^Pleroma.Plugs.RemoteIp
+ )
|> Pleroma.Repo.one()
if config do
diff --git a/priv/repo/migrations/20220319000000_add_status_to_notifications_enum.exs b/priv/repo/migrations/20220319000000_add_status_to_notifications_enum.exs
new file mode 100644
index 000000000..c3bc85894
--- /dev/null
+++ b/priv/repo/migrations/20220319000000_add_status_to_notifications_enum.exs
@@ -0,0 +1,51 @@
+defmodule Pleroma.Repo.Migrations.AddStatusToNotificationsEnum do
+ use Ecto.Migration
+
+ @disable_ddl_transaction true
+
+ def up do
+ """
+ alter type notification_type add value 'status'
+ """
+ |> execute()
+ end
+
+ def down do
+ alter table(:notifications) do
+ modify(:type, :string)
+ end
+
+ """
+ delete from notifications where type = 'status'
+ """
+ |> 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',
+ 'update'
+ )
+ """
+ |> execute()
+
+ """
+ alter table notifications
+ alter column type type notification_type using (type::notification_type)
+ """
+ |> execute()
+ end
+end
diff --git a/priv/repo/migrations/20240527144418_oban_queues_refactor.exs b/priv/repo/migrations/20240527144418_oban_queues_refactor.exs
new file mode 100644
index 000000000..64ee28dfd
--- /dev/null
+++ b/priv/repo/migrations/20240527144418_oban_queues_refactor.exs
@@ -0,0 +1,32 @@
+defmodule Pleroma.Repo.Migrations.ObanQueuesRefactor do
+ use Ecto.Migration
+
+ @changed_queues [
+ {"attachments_cleanup", "slow"},
+ {"mailer", "background"},
+ {"mute_expire", "background"},
+ {"poll_notifications", "background"},
+ {"activity_expiration", "slow"},
+ {"filter_expiration", "background"},
+ {"token_expiration", "background"},
+ {"remote_fetcher", "background"},
+ {"rich_media_expiration", "background"}
+ ]
+
+ def up do
+ Enum.each(@changed_queues, fn {old, new} ->
+ execute("UPDATE oban_jobs SET queue = '#{new}' WHERE queue = '#{old}';")
+ end)
+
+ # Handled special as reverting this would not be ideal and leaving it is harmless
+ execute(
+ "UPDATE oban_jobs SET queue = 'federator_outgoing' WHERE queue = 'scheduled_activities';"
+ )
+ end
+
+ def down do
+ # Just move all slow queue jobs to background queue if we are reverting
+ # as the slow queue will not be processing jobs
+ execute("UPDATE oban_jobs SET queue = 'background' WHERE queue = 'slow';")
+ end
+end
diff --git a/priv/repo/migrations/20240530011739_add_missing_foreign_keys.exs b/priv/repo/migrations/20240530011739_add_missing_foreign_keys.exs
new file mode 100644
index 000000000..158f9701b
--- /dev/null
+++ b/priv/repo/migrations/20240530011739_add_missing_foreign_keys.exs
@@ -0,0 +1,20 @@
+defmodule Pleroma.Repo.Migrations.AddMissingForeignKeys do
+ use Ecto.Migration
+
+ def change do
+ create_if_not_exists(index(:announcement_read_relationships, :announcement_id))
+ create_if_not_exists(index(:bookmarks, :activity_id))
+ create_if_not_exists(index(:bookmarks, :folder_id))
+ create_if_not_exists(index(:chats, :recipient))
+ create_if_not_exists(index(:mfa_tokens, :authorization_id))
+ create_if_not_exists(index(:mfa_tokens, :user_id))
+ create_if_not_exists(index(:notifications, :activity_id))
+ create_if_not_exists(index(:oauth_authorizations, :app_id))
+ create_if_not_exists(index(:oauth_authorizations, :user_id))
+ create_if_not_exists(index(:password_reset_tokens, :user_id))
+ create_if_not_exists(index(:push_subscriptions, :token_id))
+ create_if_not_exists(index(:report_notes, :activity_id))
+ create_if_not_exists(index(:report_notes, :user_id))
+ create_if_not_exists(index(:user_notes, :target_id))
+ end
+end
diff --git a/priv/repo/migrations/20240608003957_upgrade_oban_jobs_to_v12.exs b/priv/repo/migrations/20240608003957_upgrade_oban_jobs_to_v12.exs
new file mode 100644
index 000000000..ed5bf4ebb
--- /dev/null
+++ b/priv/repo/migrations/20240608003957_upgrade_oban_jobs_to_v12.exs
@@ -0,0 +1,7 @@
+defmodule Pleroma.Repo.Migrations.UpgradeObanJobsToV12 do
+ use Ecto.Migration
+
+ def up, do: Oban.Migrations.up(version: 12)
+
+ def down, do: Oban.Migrations.down(version: 12)
+end
diff --git a/priv/repo/migrations/20240619141319_deprecate_config_db_logger.exs b/priv/repo/migrations/20240619141319_deprecate_config_db_logger.exs
new file mode 100644
index 000000000..19ef0a2bb
--- /dev/null
+++ b/priv/repo/migrations/20240619141319_deprecate_config_db_logger.exs
@@ -0,0 +1,7 @@
+defmodule Pleroma.Repo.Migrations.DeprecateConfigDBLogger do
+ use Ecto.Migration
+
+ def change do
+ execute("DELETE FROM config WHERE config.group = ':logger'")
+ end
+end