move to 2.5.5
[anni] / priv / repo / migrations / 20200309123730_create_chats.exs
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
5 defmodule Pleroma.Repo.Migrations.CreateChats do
6   use Ecto.Migration
7
8   def change do
9     create table(:chats) do
10       add(:user_id, references(:users, type: :uuid))
11       # Recipient is an ActivityPub id, to future-proof for group support.
12       add(:recipient, :string)
13       add(:unread, :integer, default: 0)
14       timestamps()
15     end
16
17     # There's only one chat between a user and a recipient.
18     create(index(:chats, [:user_id, :recipient], unique: true))
19   end
20 end