From d1da6b155ab758ae4eb8fa154997a0a2a179897c Mon Sep 17 00:00:00 2001 From: lain Date: Wed, 10 Apr 2019 09:34:53 +0200 Subject: Conversation: Add Conversations and Participations. --- .../20190408123347_create_conversations.exs | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 priv/repo/migrations/20190408123347_create_conversations.exs (limited to 'priv') diff --git a/priv/repo/migrations/20190408123347_create_conversations.exs b/priv/repo/migrations/20190408123347_create_conversations.exs new file mode 100644 index 000000000..68bf766bc --- /dev/null +++ b/priv/repo/migrations/20190408123347_create_conversations.exs @@ -0,0 +1,26 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2019 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.Repo.Migrations.CreateConversations do + use Ecto.Migration + + def change do + create table(:conversations) do + add(:ap_id, :string, null: false) + timestamps() + end + + create table(:conversation_participations) do + add(:user_id, references(:users, type: :uuid, on_delete: :delete_all)) + add(:conversation_id, references(:conversations, on_delete: :delete_all)) + add(:read, :boolean, default: false) + + timestamps() + end + + create index(:conversation_participations, [:user_id]) + create index(:conversation_participations, [:conversation_id]) + create unique_index(:conversations, [:ap_id]) + end +end -- cgit v1.2.3 From 280172f6f6d74872349e3b4e6f1feaa9c95b3900 Mon Sep 17 00:00:00 2001 From: lain Date: Wed, 10 Apr 2019 16:33:45 +0200 Subject: Conversations: Create or bump on inserting a dm. --- priv/repo/migrations/20190408123347_create_conversations.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'priv') diff --git a/priv/repo/migrations/20190408123347_create_conversations.exs b/priv/repo/migrations/20190408123347_create_conversations.exs index 68bf766bc..0e0af30ae 100644 --- a/priv/repo/migrations/20190408123347_create_conversations.exs +++ b/priv/repo/migrations/20190408123347_create_conversations.exs @@ -19,8 +19,8 @@ defmodule Pleroma.Repo.Migrations.CreateConversations do timestamps() end - create index(:conversation_participations, [:user_id]) create index(:conversation_participations, [:conversation_id]) + create unique_index(:conversation_participations, [:user_id, :conversation_id]) create unique_index(:conversations, [:ap_id]) end end -- cgit v1.2.3 From de57094fca505e7dbf1a84fef5fb31fae68f2709 Mon Sep 17 00:00:00 2001 From: lain Date: Wed, 10 Apr 2019 17:30:25 +0200 Subject: Participations: Add sort index. --- .../20190410152859_add_participation_updated_at_index.exs | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 priv/repo/migrations/20190410152859_add_participation_updated_at_index.exs (limited to 'priv') diff --git a/priv/repo/migrations/20190410152859_add_participation_updated_at_index.exs b/priv/repo/migrations/20190410152859_add_participation_updated_at_index.exs new file mode 100644 index 000000000..1ce688c52 --- /dev/null +++ b/priv/repo/migrations/20190410152859_add_participation_updated_at_index.exs @@ -0,0 +1,7 @@ +defmodule Pleroma.Repo.Migrations.AddParticipationUpdatedAtIndex do + use Ecto.Migration + + def change do + create index(:conversation_participations, ["updated_at desc"]) + end +end -- cgit v1.2.3