logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

20200604150318_migrate_seen_to_unread_in_chat_message_references.exs (929B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Repo.Migrations.MigrateSeenToUnreadInChatMessageReferences do
  5. use Ecto.Migration
  6. def change do
  7. drop(
  8. index(:chat_message_references, [:chat_id],
  9. where: "seen = false",
  10. name: "unseen_messages_count_index"
  11. )
  12. )
  13. alter table(:chat_message_references) do
  14. add(:unread, :boolean, default: true)
  15. end
  16. execute("update chat_message_references set unread = not seen")
  17. alter table(:chat_message_references) do
  18. modify(:unread, :boolean, default: true, null: false)
  19. remove(:seen, :boolean, default: false, null: false)
  20. end
  21. create(
  22. index(:chat_message_references, [:chat_id],
  23. where: "unread = true",
  24. name: "unread_messages_count_index"
  25. )
  26. )
  27. end
  28. end