Purge leftovers from chats #684

Merged
floatingghost merged 2 commits from Oneric/akkoma:cosmetic-purge-chat into develop 2024-02-13 09:13:38 +00:00
2 changed files with 50 additions and 2 deletions
Showing only changes of commit 8cf183cb42 - Show all commits

View file

@ -0,0 +1,50 @@
defmodule Pleroma.Repo.Migrations.DropChatTables do
use Ecto.Migration
def up do
# Automatically drops associated indices and constraints
drop table(:chat_message_references)
drop table(:chats)
end
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

View file

@ -371,8 +371,6 @@ defmodule Mix.Tasks.Pleroma.DatabaseTest do
["apps"],
["backups"],
["bookmarks"],
["chat_message_references"],
["chats"],
["config"],
["conversation_participation_recipient_ships"],
["conversation_participations"],