mobilizon.chapril.org-mobil.../priv/repo/migrations/20200721131521_add_url_to_conversation.exs
Thomas Citharel 9c9f1385fb
Introduce group posts
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2020-07-30 16:55:35 +02:00

37 lines
1.0 KiB
Elixir

defmodule Mobilizon.Storage.Repo.Migrations.AddUrlToConversation do
use Ecto.Migration
def up do
# Just in case old name is used
drop_if_exists(constraint(:comments, :comments_conversation_id_fkey))
drop_if_exists(constraint(:comments, :comments_discussion_id_fkey))
alter table(:discussions, primary_key: false) do
remove(:id)
add(:id, :uuid, primary_key: true)
add(:url, :string, null: false)
end
alter table(:comments) do
remove(:discussion_id)
add(:discussion_id, references(:discussions, type: :uuid), null: true)
end
end
def down do
drop_if_exists(constraint(:comments, :comments_conversation_id_fkey))
drop_if_exists(constraint(:comments, :comments_discussion_id_fkey))
alter table(:discussions, primary_key: true) do
remove(:id)
add(:id, :serial, primary_key: true)
remove(:url)
end
alter table(:comments) do
remove(:discussion_id)
add(:discussion_id, references(:discussions, type: :serial), null: true)
end
end
end