Support migration from Akkoma
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
bb0cb06d8a
commit
b0b674f47e
22 changed files with 291 additions and 2 deletions
15
docs/installation/migrating_from_akkoma.md
Normal file
15
docs/installation/migrating_from_akkoma.md
Normal file
|
@ -0,0 +1,15 @@
|
|||
# Migrating from Akkoma
|
||||
|
||||
## Database migration
|
||||
|
||||
To rollback Akkoma-specific migrations:
|
||||
|
||||
- OTP: `./bin/pleroma_ctl rollback --migrations-path priv/repo/optional_migrations/akkoma_rollbacks`
|
||||
- From Source: `mix ecto.rollback --migrations-path priv/repo/optional_migrations/akkoma_rollbacks`
|
||||
|
||||
Then, just
|
||||
|
||||
- OTP: `./bin/pleroma_ctl migrate`
|
||||
- From Source: `mix ecto.migrate`
|
||||
|
||||
to apply Pleroma database migrations.
|
|
@ -7,8 +7,8 @@ defmodule Pleroma.Repo.Migrations.InstancesAddMetadata do
|
|||
|
||||
def change do
|
||||
alter table(:instances) do
|
||||
add(:metadata, :map)
|
||||
add(:metadata_updated_at, :utc_datetime)
|
||||
add_if_not_exists(:metadata, :map)
|
||||
add_if_not_exists(:metadata_updated_at, :utc_datetime)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
# Adapted from Akkoma
|
||||
# https://akkoma.dev/AkkomaGang/akkoma/src/branch/develop/priv/repo/migrations/20220108213213_add_mastofe_settings.exs
|
||||
|
||||
defmodule Pleroma.Repo.Migrations.AddMastofeSettings do
|
||||
use Ecto.Migration
|
||||
|
||||
def up, do: :ok
|
||||
|
||||
def down do
|
||||
alter table(:users) do
|
||||
remove_if_exists(:mastofe_settings, :map)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
defmodule Pleroma.Repo.Migrations.UpgradeObanToV11 do
|
||||
use Ecto.Migration
|
||||
|
||||
def change, do: :ok
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
defmodule Pleroma.Repo.Migrations.RemoveRemoteCancelledFollowRequests do
|
||||
use Ecto.Migration
|
||||
|
||||
def change, do: :ok
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
defmodule Pleroma.Repo.Migrations.RemoveLocalCancelledFollows do
|
||||
use Ecto.Migration
|
||||
|
||||
def change, do: :ok
|
||||
end
|
|
@ -0,0 +1,17 @@
|
|||
# Adapted from Akkoma
|
||||
# https://akkoma.dev/AkkomaGang/akkoma/src/branch/develop/priv/repo/migrations/20220911195347_add_user_frontend_profiles.exs
|
||||
|
||||
defmodule Pleroma.Repo.Migrations.AddUserFrontendProfiles do
|
||||
use Ecto.Migration
|
||||
|
||||
def up, do: :ok
|
||||
|
||||
def down do
|
||||
drop_if_exists(table("user_frontend_setting_profiles"))
|
||||
drop_if_exists(index(:user_frontend_setting_profiles, [:user_id, :frontend_name]))
|
||||
|
||||
drop_if_exists(
|
||||
unique_index(:user_frontend_setting_profiles, [:user_id, :frontend_name, :profile_name])
|
||||
)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,14 @@
|
|||
# Adapted from Akkoma
|
||||
# https://akkoma.dev/AkkomaGang/akkoma/src/branch/develop/priv/repo/migrations/20220916115149_ensure_mastofe_settings.exs
|
||||
|
||||
defmodule Pleroma.Repo.Migrations.EnsureMastofeSettings do
|
||||
use Ecto.Migration
|
||||
|
||||
def up, do: :ok
|
||||
|
||||
def down do
|
||||
alter table(:users) do
|
||||
remove_if_exists(:mastofe_settings, :map)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,15 @@
|
|||
# Adapted from Akkoma
|
||||
# https://akkoma.dev/AkkomaGang/akkoma/src/branch/develop/priv/repo/migrations/20221020135943_add_nodeinfo.exs
|
||||
|
||||
defmodule Pleroma.Repo.Migrations.AddNodeinfo do
|
||||
use Ecto.Migration
|
||||
|
||||
def up, do: :ok
|
||||
|
||||
def down do
|
||||
alter table(:instances) do
|
||||
remove_if_exists(:nodeinfo, :map)
|
||||
remove_if_exists(:metadata_updated_at, :naive_datetime)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,12 @@
|
|||
# Adapted from Akkoma
|
||||
# https://akkoma.dev/AkkomaGang/akkoma/src/branch/develop/priv/repo/migrations/20221123221956_add_has_request_signatures.exs
|
||||
|
||||
defmodule Pleroma.Repo.Migrations.AddHasRequestSignatures do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
alter table(:instances) do
|
||||
add(:has_request_signatures, :boolean, default: false, null: false)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,12 @@
|
|||
# Adapted from Akkoma
|
||||
# https://akkoma.dev/AkkomaGang/akkoma/src/branch/develop/priv/repo/migrations/20221128103145_add_per_user_post_expiry.exs
|
||||
|
||||
defmodule Pleroma.Repo.Migrations.AddPerUserPostExpiry do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
alter table(:users) do
|
||||
add(:status_ttl_days, :integer, null: true)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
defmodule Pleroma.Repo.Migrations.AddNotificationActivityIdIndex do
|
||||
use Ecto.Migration
|
||||
|
||||
def change, do: :ok
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
defmodule Pleroma.Repo.Migrations.AddBookmarksActivityIdIndex do
|
||||
use Ecto.Migration
|
||||
|
||||
def change, do: :ok
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
defmodule Pleroma.Repo.Migrations.AddReportNotesActivityIdIndex do
|
||||
use Ecto.Migration
|
||||
|
||||
def change, do: :ok
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
# Adapted from Akkoma
|
||||
# https://akkoma.dev/AkkomaGang/akkoma/src/branch/develop/priv/repo/migrations/20221129112022_add_cascade_to_report_notes_on_activity_delete.exs
|
||||
|
||||
defmodule Pleroma.Repo.Migrations.AddCascadeToReportNotesOnActivityDelete do
|
||||
use Ecto.Migration
|
||||
|
||||
def up, do: :ok
|
||||
|
||||
def down do
|
||||
drop(constraint(:report_notes, "report_notes_activity_id_fkey"))
|
||||
|
||||
alter table(:report_notes) do
|
||||
modify(:activity_id, references(:activities, type: :uuid))
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,17 @@
|
|||
# Adapted from Akkoma
|
||||
# https://akkoma.dev/AkkomaGang/akkoma/src/branch/develop/priv/repo/migrations/20221203232118_add_user_follows_hashtag.exs
|
||||
|
||||
defmodule Pleroma.Repo.Migrations.AddUserFollowsHashtag do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:user_follows_hashtag) do
|
||||
add(:hashtag_id, references(:hashtags))
|
||||
add(:user_id, references(:users, type: :uuid, on_delete: :delete_all))
|
||||
end
|
||||
|
||||
create(unique_index(:user_follows_hashtag, [:user_id, :hashtag_id]))
|
||||
|
||||
create_if_not_exists(index(:user_follows_hashtag, [:hashtag_id]))
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
defmodule Pleroma.Repo.Migrations.RemoveUnusedIndices do
|
||||
use Ecto.Migration
|
||||
|
||||
def change, do: :ok
|
||||
end
|
|
@ -0,0 +1,15 @@
|
|||
# Adapted from Akkoma
|
||||
# https://akkoma.dev/AkkomaGang/akkoma/src/branch/develop/priv/repo/migrations/20230127143303_rename_index_users_ap_id_coalesce_follower_address_index.exs
|
||||
|
||||
defmodule Pleroma.Repo.Migrations.RenameIndexUsersApId_COALESCEFollowerAddressIndex do
|
||||
alias Pleroma.Repo
|
||||
|
||||
use Ecto.Migration
|
||||
|
||||
def up, do: :ok
|
||||
|
||||
def down do
|
||||
Repo.query!("ALTER INDEX public.\"aa_users_ap_id_COALESCE_follower_address_index\"
|
||||
RENAME TO \"users_ap_id_COALESCE_follower_address_index\";")
|
||||
end
|
||||
end
|
|
@ -0,0 +1,12 @@
|
|||
# Adapted from Akkoma
|
||||
# https://akkoma.dev/AkkomaGang/akkoma/src/branch/develop/priv/repo/migrations/20230522213837_add_unfollowed_dm_restrictions.exs
|
||||
|
||||
defmodule Pleroma.Repo.Migrations.AddUnfollowedDmRestrictions do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
alter table(:users) do
|
||||
add(:accepts_direct_messages_from, :string, default: "everybody")
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,49 @@
|
|||
# Adapted from Akkoma
|
||||
# https://akkoma.dev/AkkomaGang/akkoma/src/branch/develop/priv/repo/migrations/20240210000000_drop_chat_tables.exs
|
||||
|
||||
defmodule Pleroma.Repo.Migrations.DropChatTables do
|
||||
use Ecto.Migration
|
||||
|
||||
def up, do: :ok
|
||||
|
||||
def down do
|
||||
# Ecto's default primary key is bigserial, thus configure manually
|
||||
create table(:chats, primary_key: false) do
|
||||
add(:id, :uuid, primary_key: true, autogenerated: true)
|
||||
|
||||
add(
|
||||
:user_id,
|
||||
references(:users, type: :uuid, on_delete: :delete_all)
|
||||
# yes, this was nullable
|
||||
)
|
||||
|
||||
add(
|
||||
:recipient,
|
||||
references(:users, column: :ap_id, type: :string, on_delete: :delete_all)
|
||||
# yes, this was nullable
|
||||
)
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
create(index(:chats, [:user_id, :recipient], unique: true))
|
||||
|
||||
create table(:chat_message_references, primary_key: false) do
|
||||
add(:id, :uuid, primary_key: true, autogenerated: true)
|
||||
add(:chat_id, references(:chats, type: :uuid, on_delete: :delete_all), null: false)
|
||||
add(:object_id, references(:objects, on_delete: :delete_all), null: false)
|
||||
add(:unread, :boolean, default: true, null: false)
|
||||
timestamps()
|
||||
end
|
||||
|
||||
create(index(:chat_message_references, [:chat_id, "id desc"]))
|
||||
create(unique_index(:chat_message_references, [:object_id, :chat_id]))
|
||||
|
||||
create(
|
||||
index(:chat_message_references, [:chat_id],
|
||||
where: "unread = true",
|
||||
name: "unread_messages_count_index"
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,12 @@
|
|||
# Adapted from Akkoma
|
||||
# https://akkoma.dev/AkkomaGang/akkoma/src/branch/develop/priv/repo/migrations/20240213120000_add_permit_followback.exs
|
||||
|
||||
defmodule Pleroma.Repo.Migrations.AddPermitFollowback do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
alter table(:users) do
|
||||
add(:permit_followback, :boolean, null: false, default: false)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,34 @@
|
|||
# Adapted from Akkoma
|
||||
# https://akkoma.dev/AkkomaGang/akkoma/src/branch/develop/priv/repo/migrations/20240425120000_upload_filter_exiftool_to_exiftool_strip_location_real.exs
|
||||
|
||||
defmodule Pleroma.Repo.Migrations.UploadFilterExiftoolToExiftoolStripMetadataReal do
|
||||
use Ecto.Migration
|
||||
|
||||
alias Pleroma.ConfigDB
|
||||
|
||||
def up, do: :ok
|
||||
|
||||
def down,
|
||||
do:
|
||||
ConfigDB.get_by_params(%{group: :pleroma, key: Pleroma.Upload})
|
||||
|> update_filtername(
|
||||
Pleroma.Upload.Filter.Exiftool.StripMetadata,
|
||||
Pleroma.Upload.Filter.Exiftool
|
||||
)
|
||||
|
||||
defp update_filtername(%{value: value}, from_filtername, to_filtername) do
|
||||
new_value =
|
||||
value
|
||||
|> Keyword.update(:filters, [], fn filters ->
|
||||
filters
|
||||
|> Enum.map(fn
|
||||
^from_filtername -> to_filtername
|
||||
filter -> filter
|
||||
end)
|
||||
end)
|
||||
|
||||
ConfigDB.update_or_create(%{group: :pleroma, key: Pleroma.Upload, value: new_value})
|
||||
end
|
||||
|
||||
defp update_filtername(_, _, _), do: nil
|
||||
end
|
Loading…
Reference in a new issue