Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into remake-remodel-dms
[akkoma] / priv / repo / migrations / 20200309123730_create_chats.exs
1 defmodule Pleroma.Repo.Migrations.CreateChats do
2 use Ecto.Migration
3
4 def change do
5 create table(:chats) do
6 add(:user_id, references(:users, type: :uuid))
7 # Recipient is an ActivityPub id, to future-proof for group support.
8 add(:recipient, :string)
9 add(:unread, :integer, default: 0)
10 timestamps()
11 end
12
13 # There's only one chat between a user and a recipient.
14 create(index(:chats, [:user_id, :recipient], unique: true))
15 end
16 end