debianize-mobilizon/priv/repo/migrations/20230920071502_add_actor_conversations.exs
Thomas Citharel b5672cee7e
WIP
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2023-11-14 14:24:17 +01:00

38 lines
1.0 KiB
Elixir

defmodule Mobilizon.Storage.Repo.Migrations.AddActorConversations do
use Ecto.Migration
def up do
create table(:conversations) do
add(:event_id, references(:events, on_delete: :delete_all), null: true)
add(:origin_comment_id, references(:comments, on_delete: :delete_all), null: false)
add(:last_comment_id, references(:comments, on_delete: :delete_all), null: false)
timestamps()
end
create table(:conversation_participants) do
add(:conversation_id, references(:conversations, on_delete: :delete_all), null: false)
add(:actor_id, references(:actors, on_delete: :delete_all), null: false)
add(:unread, :boolean, default_value: true)
timestamps()
end
alter table(:comments) do
add(:conversation_id, references(:conversations, on_delete: :delete_all), null: true)
end
end
def down do
drop table(:conversation_participants)
alter table(:comments) do
remove(:conversation_id)
end
drop table(:conversations)
end
end