1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Repo.Migrations.CreateConversations do
9 create_if_not_exists table(:conversations) do
10 add(:ap_id, :string, null: false)
14 create_if_not_exists table(:conversation_participations) do
15 add(:user_id, references(:users, type: :uuid, on_delete: :delete_all))
16 add(:conversation_id, references(:conversations, on_delete: :delete_all))
17 add(:read, :boolean, default: false)
22 create_if_not_exists(index(:conversation_participations, [:conversation_id]))
23 create_if_not_exists(unique_index(:conversation_participations, [:user_id, :conversation_id]))
24 create_if_not_exists(unique_index(:conversations, [:ap_id]))