Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
770B

  1. defmodule Pleroma.Repo.Migrations.MigrateSeenToUnreadInChatMessageReferences do
  2. use Ecto.Migration
  3. def change do
  4. drop(
  5. index(:chat_message_references, [:chat_id],
  6. where: "seen = false",
  7. name: "unseen_messages_count_index"
  8. )
  9. )
  10. alter table(:chat_message_references) do
  11. add(:unread, :boolean, default: true)
  12. end
  13. execute("update chat_message_references set unread = not seen")
  14. alter table(:chat_message_references) do
  15. modify(:unread, :boolean, default: true, null: false)
  16. remove(:seen, :boolean, default: false, null: false)
  17. end
  18. create(
  19. index(:chat_message_references, [:chat_id],
  20. where: "unread = true",
  21. name: "unread_messages_count_index"
  22. )
  23. )
  24. end
  25. end