summaryrefslogtreecommitdiff
path: root/priv/repo/migrations
diff options
context:
space:
mode:
Diffstat (limited to 'priv/repo/migrations')
-rw-r--r--priv/repo/migrations/20190408123347_create_conversations.exs2
-rw-r--r--priv/repo/migrations/20190730055101_add_oban_jobs_table.exs5
-rw-r--r--priv/repo/migrations/20190917100019_update_oban.exs2
-rw-r--r--priv/repo/migrations/20200402063221_update_oban_jobs_table.exs2
-rw-r--r--priv/repo/migrations/20200602150528_create_chat_message_reference.exs2
-rw-r--r--priv/repo/migrations/20200825061316_move_activity_expirations_to_oban.exs2
-rw-r--r--priv/repo/migrations/20200831114918_remove_unread_conversation_count_from_user.exs38
-rw-r--r--priv/repo/migrations/20200831115854_add_unread_index_to_conversation_participation.exs12
-rw-r--r--priv/repo/migrations/20200831152600_add_pleroma_report_to_enum_for_notifications.exs48
-rw-r--r--priv/repo/migrations/20200831192323_create_backups.exs17
-rw-r--r--priv/repo/migrations/20200907092050_move_tokens_expiration_into_oban.exs2
-rw-r--r--priv/repo/migrations/20200915095704_remove_background_jobs.exs22
-rw-r--r--priv/repo/migrations/20201012173004_refactor_deactivated_user_field.exs22
-rw-r--r--priv/repo/migrations/20201013141127_refactor_locked_user_field.exs2
-rw-r--r--priv/repo/migrations/20201013144052_refactor_discoverable_user_field.exs15
-rw-r--r--priv/repo/migrations/20201013184200_refactor_confirmation_pending_user_field.exs20
-rw-r--r--priv/repo/migrations/20201016205220_refactor_approval_pending_user_field.exs20
-rw-r--r--priv/repo/migrations/20201217172858_data_migration_prolong_o_auth_tokens_valid_until.exs13
-rw-r--r--priv/repo/migrations/20201231185546_confirm_logged_in_users.exs22
-rw-r--r--priv/repo/migrations/20210113225652_deprecate_public_endpoint.exs57
-rw-r--r--priv/repo/migrations/20210115205649_upgrade_oban_jobs_to_v9.exs15
-rw-r--r--priv/repo/migrations/20210121080964_add_default_text_search_config.exs11
-rw-r--r--priv/repo/migrations/20210122151424_add_last_active_at_to_users.exs11
-rw-r--r--priv/repo/migrations/20210128092834_remove_duplicates_from_activity_expiration_queue.exs29
-rw-r--r--priv/repo/migrations/20210218223811_add_disclose_client_to_users.exs9
25 files changed, 394 insertions, 6 deletions
diff --git a/priv/repo/migrations/20190408123347_create_conversations.exs b/priv/repo/migrations/20190408123347_create_conversations.exs
index 3eaa6136c..aab6cf802 100644
--- a/priv/repo/migrations/20190408123347_create_conversations.exs
+++ b/priv/repo/migrations/20190408123347_create_conversations.exs
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Repo.Migrations.CreateConversations do
diff --git a/priv/repo/migrations/20190730055101_add_oban_jobs_table.exs b/priv/repo/migrations/20190730055101_add_oban_jobs_table.exs
index 2f201bd05..5214d59cb 100644
--- a/priv/repo/migrations/20190730055101_add_oban_jobs_table.exs
+++ b/priv/repo/migrations/20190730055101_add_oban_jobs_table.exs
@@ -1,6 +1,9 @@
defmodule Pleroma.Repo.Migrations.AddObanJobsTable do
use Ecto.Migration
- defdelegate up, to: Oban.Migrations
+ def up do
+ Oban.Migrations.up(version: 2)
+ end
+
defdelegate down, to: Oban.Migrations
end
diff --git a/priv/repo/migrations/20190917100019_update_oban.exs b/priv/repo/migrations/20190917100019_update_oban.exs
index 157dc54f9..f673675de 100644
--- a/priv/repo/migrations/20190917100019_update_oban.exs
+++ b/priv/repo/migrations/20190917100019_update_oban.exs
@@ -6,6 +6,6 @@ defmodule Pleroma.Repo.Migrations.UpdateOban do
end
def down do
- Oban.Migrations.down(version: 2)
+ Oban.Migrations.down(version: 3)
end
end
diff --git a/priv/repo/migrations/20200402063221_update_oban_jobs_table.exs b/priv/repo/migrations/20200402063221_update_oban_jobs_table.exs
index e7ff04008..ca6856798 100644
--- a/priv/repo/migrations/20200402063221_update_oban_jobs_table.exs
+++ b/priv/repo/migrations/20200402063221_update_oban_jobs_table.exs
@@ -6,6 +6,6 @@ defmodule Pleroma.Repo.Migrations.UpdateObanJobsTable do
end
def down do
- Oban.Migrations.down(version: 7)
+ Oban.Migrations.down(version: 8)
end
end
diff --git a/priv/repo/migrations/20200602150528_create_chat_message_reference.exs b/priv/repo/migrations/20200602150528_create_chat_message_reference.exs
index 6f9148b7c..5e57cddcf 100644
--- a/priv/repo/migrations/20200602150528_create_chat_message_reference.exs
+++ b/priv/repo/migrations/20200602150528_create_chat_message_reference.exs
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Repo.Migrations.CreateChatMessageReference do
diff --git a/priv/repo/migrations/20200825061316_move_activity_expirations_to_oban.exs b/priv/repo/migrations/20200825061316_move_activity_expirations_to_oban.exs
index a703af83f..096ab4ce5 100644
--- a/priv/repo/migrations/20200825061316_move_activity_expirations_to_oban.exs
+++ b/priv/repo/migrations/20200825061316_move_activity_expirations_to_oban.exs
@@ -6,6 +6,8 @@ defmodule Pleroma.Repo.Migrations.MoveActivityExpirationsToOban do
def change do
Pleroma.Config.Oban.warn()
+ Application.ensure_all_started(:oban)
+
Supervisor.start_link([{Oban, Pleroma.Config.get(Oban)}],
strategy: :one_for_one,
name: Pleroma.Supervisor
diff --git a/priv/repo/migrations/20200831114918_remove_unread_conversation_count_from_user.exs b/priv/repo/migrations/20200831114918_remove_unread_conversation_count_from_user.exs
new file mode 100644
index 000000000..b7bdb9166
--- /dev/null
+++ b/priv/repo/migrations/20200831114918_remove_unread_conversation_count_from_user.exs
@@ -0,0 +1,38 @@
+defmodule Pleroma.Repo.Migrations.RemoveUnreadConversationCountFromUser do
+ use Ecto.Migration
+ import Ecto.Query
+ alias Pleroma.Repo
+
+ def up do
+ alter table(:users) do
+ remove_if_exists(:unread_conversation_count, :integer)
+ end
+ end
+
+ def down do
+ alter table(:users) do
+ add_if_not_exists(:unread_conversation_count, :integer, default: 0)
+ end
+
+ flush()
+ recalc_unread_conversation_count()
+ end
+
+ defp recalc_unread_conversation_count do
+ participations_subquery =
+ from(
+ p in "conversation_participations",
+ where: p.read == false,
+ group_by: p.user_id,
+ select: %{user_id: p.user_id, unread_conversation_count: count(p.id)}
+ )
+
+ from(
+ u in "users",
+ join: p in subquery(participations_subquery),
+ on: p.user_id == u.id,
+ update: [set: [unread_conversation_count: p.unread_conversation_count]]
+ )
+ |> Repo.update_all([])
+ end
+end
diff --git a/priv/repo/migrations/20200831115854_add_unread_index_to_conversation_participation.exs b/priv/repo/migrations/20200831115854_add_unread_index_to_conversation_participation.exs
new file mode 100644
index 000000000..68771c655
--- /dev/null
+++ b/priv/repo/migrations/20200831115854_add_unread_index_to_conversation_participation.exs
@@ -0,0 +1,12 @@
+defmodule Pleroma.Repo.Migrations.AddUnreadIndexToConversationParticipation do
+ use Ecto.Migration
+
+ def change do
+ create(
+ index(:conversation_participations, [:user_id],
+ where: "read = false",
+ name: "unread_conversation_participation_count_index"
+ )
+ )
+ end
+end
diff --git a/priv/repo/migrations/20200831152600_add_pleroma_report_to_enum_for_notifications.exs b/priv/repo/migrations/20200831152600_add_pleroma_report_to_enum_for_notifications.exs
new file mode 100644
index 000000000..01fb90459
--- /dev/null
+++ b/priv/repo/migrations/20200831152600_add_pleroma_report_to_enum_for_notifications.exs
@@ -0,0 +1,48 @@
+defmodule Pleroma.Repo.Migrations.AddPleromaReportTypeToEnumForNotifications do
+ use Ecto.Migration
+
+ @disable_ddl_transaction true
+
+ def up do
+ """
+ alter type notification_type add value 'pleroma:report'
+ """
+ |> execute()
+ end
+
+ def down do
+ alter table(:notifications) do
+ modify(:type, :string)
+ end
+
+ """
+ delete from notifications where type = 'pleroma:report'
+ """
+ |> 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'
+ )
+ """
+ |> execute()
+
+ """
+ alter table notifications
+ alter column type type notification_type using (type::notification_type)
+ """
+ |> execute()
+ end
+end
diff --git a/priv/repo/migrations/20200831192323_create_backups.exs b/priv/repo/migrations/20200831192323_create_backups.exs
new file mode 100644
index 000000000..3ac5889e2
--- /dev/null
+++ b/priv/repo/migrations/20200831192323_create_backups.exs
@@ -0,0 +1,17 @@
+defmodule Pleroma.Repo.Migrations.CreateBackups do
+ use Ecto.Migration
+
+ def change do
+ create_if_not_exists table(:backups) do
+ add(:user_id, references(:users, type: :uuid, on_delete: :delete_all))
+ add(:file_name, :string, null: false)
+ add(:content_type, :string, null: false)
+ add(:processed, :boolean, null: false, default: false)
+ add(:file_size, :bigint)
+
+ timestamps()
+ end
+
+ create_if_not_exists(index(:backups, [:user_id]))
+ end
+end
diff --git a/priv/repo/migrations/20200907092050_move_tokens_expiration_into_oban.exs b/priv/repo/migrations/20200907092050_move_tokens_expiration_into_oban.exs
index 9e49ddacb..725c5ab0b 100644
--- a/priv/repo/migrations/20200907092050_move_tokens_expiration_into_oban.exs
+++ b/priv/repo/migrations/20200907092050_move_tokens_expiration_into_oban.exs
@@ -6,6 +6,8 @@ defmodule Pleroma.Repo.Migrations.MoveTokensExpirationIntoOban do
def change do
Pleroma.Config.Oban.warn()
+ Application.ensure_all_started(:oban)
+
Supervisor.start_link([{Oban, Pleroma.Config.get(Oban)}],
strategy: :one_for_one,
name: Pleroma.Supervisor
diff --git a/priv/repo/migrations/20200915095704_remove_background_jobs.exs b/priv/repo/migrations/20200915095704_remove_background_jobs.exs
new file mode 100644
index 000000000..9785bfb8a
--- /dev/null
+++ b/priv/repo/migrations/20200915095704_remove_background_jobs.exs
@@ -0,0 +1,22 @@
+defmodule Pleroma.Repo.Migrations.RemoveBackgroundJobs do
+ use Ecto.Migration
+
+ import Ecto.Query, only: [from: 2]
+
+ def up do
+ from(j in "oban_jobs",
+ where:
+ j.queue == ^"background" and
+ fragment("?->>'op'", j.args) in ^[
+ "fetch_data_for_activity",
+ "media_proxy_prefetch",
+ "media_proxy_preload"
+ ] and
+ j.worker == ^"Pleroma.Workers.BackgroundWorker",
+ select: [:id]
+ )
+ |> Pleroma.Repo.delete_all()
+ end
+
+ def down, do: :ok
+end
diff --git a/priv/repo/migrations/20201012173004_refactor_deactivated_user_field.exs b/priv/repo/migrations/20201012173004_refactor_deactivated_user_field.exs
new file mode 100644
index 000000000..58b75b436
--- /dev/null
+++ b/priv/repo/migrations/20201012173004_refactor_deactivated_user_field.exs
@@ -0,0 +1,22 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Repo.Migrations.RefactorDeactivatedUserField do
+ use Ecto.Migration
+
+ def up do
+ # Flip the values before we change the meaning of the column
+ execute("UPDATE users SET deactivated = NOT deactivated;")
+ execute("ALTER TABLE users RENAME COLUMN deactivated TO is_active;")
+ execute("ALTER TABLE users ALTER COLUMN is_active SET DEFAULT true;")
+ execute("ALTER INDEX users_deactivated_index RENAME TO users_is_active_index;")
+ end
+
+ def down do
+ execute("UPDATE users SET is_active = NOT is_active;")
+ execute("ALTER TABLE users RENAME COLUMN is_active TO deactivated;")
+ execute("ALTER TABLE users ALTER COLUMN deactivated SET DEFAULT false;")
+ execute("ALTER INDEX users_is_active_index RENAME TO users_deactivated_index;")
+ end
+end
diff --git a/priv/repo/migrations/20201013141127_refactor_locked_user_field.exs b/priv/repo/migrations/20201013141127_refactor_locked_user_field.exs
index 6cd23dbac..3fb643372 100644
--- a/priv/repo/migrations/20201013141127_refactor_locked_user_field.exs
+++ b/priv/repo/migrations/20201013141127_refactor_locked_user_field.exs
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Repo.Migrations.RefactorLockedUserField do
diff --git a/priv/repo/migrations/20201013144052_refactor_discoverable_user_field.exs b/priv/repo/migrations/20201013144052_refactor_discoverable_user_field.exs
new file mode 100644
index 000000000..6d6738e90
--- /dev/null
+++ b/priv/repo/migrations/20201013144052_refactor_discoverable_user_field.exs
@@ -0,0 +1,15 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Repo.Migrations.RefactorDiscoverableUserField do
+ use Ecto.Migration
+
+ def up do
+ execute("ALTER TABLE users RENAME COLUMN discoverable TO is_discoverable;")
+ end
+
+ def down do
+ execute("ALTER TABLE users RENAME COLUMN is_discoverable TO discoverable;")
+ end
+end
diff --git a/priv/repo/migrations/20201013184200_refactor_confirmation_pending_user_field.exs b/priv/repo/migrations/20201013184200_refactor_confirmation_pending_user_field.exs
new file mode 100644
index 000000000..d0dc42827
--- /dev/null
+++ b/priv/repo/migrations/20201013184200_refactor_confirmation_pending_user_field.exs
@@ -0,0 +1,20 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Repo.Migrations.RefactorConfirmationPendingUserField do
+ use Ecto.Migration
+
+ def up do
+ # Flip the values before we change the meaning of the column
+ execute("UPDATE users SET confirmation_pending = NOT confirmation_pending;")
+ execute("ALTER TABLE users RENAME COLUMN confirmation_pending TO is_confirmed;")
+ execute("ALTER TABLE users ALTER COLUMN is_confirmed SET DEFAULT true;")
+ end
+
+ def down do
+ execute("UPDATE users SET is_confirmed = NOT is_confirmed;")
+ execute("ALTER TABLE users RENAME COLUMN is_confirmed TO confirmation_pending;")
+ execute("ALTER TABLE users ALTER COLUMN confirmation_pending SET DEFAULT false;")
+ end
+end
diff --git a/priv/repo/migrations/20201016205220_refactor_approval_pending_user_field.exs b/priv/repo/migrations/20201016205220_refactor_approval_pending_user_field.exs
new file mode 100644
index 000000000..944dcf8de
--- /dev/null
+++ b/priv/repo/migrations/20201016205220_refactor_approval_pending_user_field.exs
@@ -0,0 +1,20 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Repo.Migrations.RefactorApprovalPendingUserField do
+ use Ecto.Migration
+
+ def up do
+ # Flip the values before we change the meaning of the column
+ execute("UPDATE users SET approval_pending = NOT approval_pending;")
+ execute("ALTER TABLE users RENAME COLUMN approval_pending TO is_approved;")
+ execute("ALTER TABLE users ALTER COLUMN is_approved SET DEFAULT true;")
+ end
+
+ def down do
+ execute("UPDATE users SET is_approved = NOT is_approved;")
+ execute("ALTER TABLE users RENAME COLUMN is_approved TO approval_pending;")
+ execute("ALTER TABLE users ALTER COLUMN approval_pending SET DEFAULT false;")
+ end
+end
diff --git a/priv/repo/migrations/20201217172858_data_migration_prolong_o_auth_tokens_valid_until.exs b/priv/repo/migrations/20201217172858_data_migration_prolong_o_auth_tokens_valid_until.exs
new file mode 100644
index 000000000..560cc7447
--- /dev/null
+++ b/priv/repo/migrations/20201217172858_data_migration_prolong_o_auth_tokens_valid_until.exs
@@ -0,0 +1,13 @@
+defmodule Pleroma.Repo.Migrations.DataMigrationProlongOAuthTokensValidUntil do
+ use Ecto.Migration
+
+ def up do
+ expires_in = Pleroma.Config.get!([:oauth2, :token_expires_in])
+ valid_until = NaiveDateTime.add(NaiveDateTime.utc_now(), expires_in, :second)
+ execute("update oauth_tokens set valid_until = '#{valid_until}'")
+ end
+
+ def down do
+ :noop
+ end
+end
diff --git a/priv/repo/migrations/20201231185546_confirm_logged_in_users.exs b/priv/repo/migrations/20201231185546_confirm_logged_in_users.exs
new file mode 100644
index 000000000..b9656c17b
--- /dev/null
+++ b/priv/repo/migrations/20201231185546_confirm_logged_in_users.exs
@@ -0,0 +1,22 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Repo.Migrations.ConfirmLoggedInUsers do
+ use Ecto.Migration
+ import Ecto.Query
+ alias Pleroma.Repo
+ alias Pleroma.User
+ alias Pleroma.Web.OAuth.Token
+
+ def up do
+ User
+ |> where([u], u.is_confirmed == false)
+ |> join(:inner, [u], t in Token, on: t.user_id == u.id)
+ |> Repo.update_all(set: [is_confirmed: true])
+ end
+
+ def down do
+ :noop
+ end
+end
diff --git a/priv/repo/migrations/20210113225652_deprecate_public_endpoint.exs b/priv/repo/migrations/20210113225652_deprecate_public_endpoint.exs
new file mode 100644
index 000000000..6f470a459
--- /dev/null
+++ b/priv/repo/migrations/20210113225652_deprecate_public_endpoint.exs
@@ -0,0 +1,57 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Repo.Migrations.DeprecatePublicEndpoint do
+ use Ecto.Migration
+
+ def up do
+ with %Pleroma.ConfigDB{} = s3_config <-
+ Pleroma.ConfigDB.get_by_params(%{group: :pleroma, key: Pleroma.Uploaders.S3}),
+ %Pleroma.ConfigDB{} = upload_config <-
+ Pleroma.ConfigDB.get_by_params(%{group: :pleroma, key: Pleroma.Upload}) do
+ public_endpoint = s3_config.value[:public_endpoint]
+
+ if !is_nil(public_endpoint) do
+ upload_value = upload_config.value |> Keyword.merge(base_url: public_endpoint)
+
+ upload_config
+ |> Ecto.Changeset.change(value: upload_value)
+ |> Pleroma.Repo.update()
+
+ s3_value = s3_config.value |> Keyword.delete(:public_endpoint)
+
+ s3_config
+ |> Ecto.Changeset.change(value: s3_value)
+ |> Pleroma.Repo.update()
+ end
+ else
+ _ -> :ok
+ end
+ end
+
+ def down do
+ with %Pleroma.ConfigDB{} = upload_config <-
+ Pleroma.ConfigDB.get_by_params(%{group: :pleroma, key: Pleroma.Upload}),
+ %Pleroma.ConfigDB{} = s3_config <-
+ Pleroma.ConfigDB.get_by_params(%{group: :pleroma, key: Pleroma.Uploaders.S3}) do
+ base_url = upload_config.value[:base_url]
+
+ if !is_nil(base_url) do
+ s3_value = s3_config.value |> Keyword.merge(public_endpoint: base_url)
+
+ s3_config
+ |> Ecto.Changeset.change(value: s3_value)
+ |> Pleroma.Repo.update()
+
+ upload_value = upload_config.value |> Keyword.delete(:base_url)
+
+ upload_config
+ |> Ecto.Changeset.change(value: upload_value)
+ |> Pleroma.Repo.update()
+ end
+ else
+ _ -> :ok
+ end
+ end
+end
diff --git a/priv/repo/migrations/20210115205649_upgrade_oban_jobs_to_v9.exs b/priv/repo/migrations/20210115205649_upgrade_oban_jobs_to_v9.exs
new file mode 100644
index 000000000..bfb405579
--- /dev/null
+++ b/priv/repo/migrations/20210115205649_upgrade_oban_jobs_to_v9.exs
@@ -0,0 +1,15 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Repo.Migrations.UpgradeObanJobsToV9 do
+ use Ecto.Migration
+
+ def up do
+ Oban.Migrations.up(version: 9)
+ end
+
+ def down do
+ Oban.Migrations.down(version: 9)
+ end
+end
diff --git a/priv/repo/migrations/20210121080964_add_default_text_search_config.exs b/priv/repo/migrations/20210121080964_add_default_text_search_config.exs
new file mode 100644
index 000000000..09b6cccc9
--- /dev/null
+++ b/priv/repo/migrations/20210121080964_add_default_text_search_config.exs
@@ -0,0 +1,11 @@
+defmodule Pleroma.Repo.Migrations.AddDefaultTextSearchConfig do
+ use Ecto.Migration
+
+ def change do
+ execute("DO $$
+ BEGIN
+ execute 'ALTER DATABASE '||current_database()||' SET default_text_search_config = ''english'' ';
+ END
+ $$;")
+ end
+end
diff --git a/priv/repo/migrations/20210122151424_add_last_active_at_to_users.exs b/priv/repo/migrations/20210122151424_add_last_active_at_to_users.exs
new file mode 100644
index 000000000..9671e495b
--- /dev/null
+++ b/priv/repo/migrations/20210122151424_add_last_active_at_to_users.exs
@@ -0,0 +1,11 @@
+defmodule Pleroma.Repo.Migrations.AddLastActiveAtToUsers do
+ use Ecto.Migration
+
+ def change do
+ alter table(:users) do
+ add(:last_active_at, :naive_datetime)
+ end
+
+ create_if_not_exists(index(:users, [:last_active_at]))
+ end
+end
diff --git a/priv/repo/migrations/20210128092834_remove_duplicates_from_activity_expiration_queue.exs b/priv/repo/migrations/20210128092834_remove_duplicates_from_activity_expiration_queue.exs
new file mode 100644
index 000000000..309009205
--- /dev/null
+++ b/priv/repo/migrations/20210128092834_remove_duplicates_from_activity_expiration_queue.exs
@@ -0,0 +1,29 @@
+defmodule Pleroma.Repo.Migrations.RemoveDuplicatesFromActivityExpirationQueue do
+ use Ecto.Migration
+
+ import Ecto.Query, only: [from: 2]
+
+ def up do
+ duplicate_ids =
+ from(j in Oban.Job,
+ where: j.queue == "activity_expiration",
+ where: j.worker == "Pleroma.Workers.PurgeExpiredActivity",
+ where: j.state == "scheduled",
+ select:
+ {fragment("(?)->>'activity_id'", j.args), fragment("array_agg(?)", j.id), count(j.id)},
+ group_by: fragment("(?)->>'activity_id'", j.args),
+ having: count(j.id) > 1
+ )
+ |> Pleroma.Repo.all()
+ |> Enum.map(fn {_, ids, _} ->
+ max_id = Enum.max(ids)
+ List.delete(ids, max_id)
+ end)
+ |> List.flatten()
+
+ from(j in Oban.Job, where: j.id in ^duplicate_ids)
+ |> Pleroma.Repo.delete_all()
+ end
+
+ def down, do: :noop
+end
diff --git a/priv/repo/migrations/20210218223811_add_disclose_client_to_users.exs b/priv/repo/migrations/20210218223811_add_disclose_client_to_users.exs
new file mode 100644
index 000000000..37c5776ff
--- /dev/null
+++ b/priv/repo/migrations/20210218223811_add_disclose_client_to_users.exs
@@ -0,0 +1,9 @@
+defmodule Pleroma.Repo.Migrations.AddDiscloseClientToUsers do
+ use Ecto.Migration
+
+ def change do
+ alter table(:users) do
+ add(:disclose_client, :boolean, default: true)
+ end
+ end
+end