2018-11-08 17:57:10 +01:00
|
|
|
defmodule Mobilizon.Repo.Migrations.FixCommentsReferences do
|
|
|
|
@moduledoc """
|
|
|
|
For some reason these fields references were all wrong.
|
|
|
|
"""
|
|
|
|
use Ecto.Migration
|
|
|
|
|
|
|
|
def up do
|
2019-02-22 14:18:52 +01:00
|
|
|
drop(constraint(:comments, "comments_in_reply_to_comment_id_fkey"))
|
|
|
|
drop(constraint(:comments, "comments_origin_comment_id_fkey"))
|
2018-11-08 17:57:10 +01:00
|
|
|
|
|
|
|
alter table(:comments) do
|
2019-02-22 14:18:52 +01:00
|
|
|
modify(:in_reply_to_comment_id, references(:comments, on_delete: :nothing))
|
|
|
|
modify(:origin_comment_id, references(:comments, on_delete: :nothing))
|
2018-11-08 17:57:10 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def down do
|
2019-02-22 14:18:52 +01:00
|
|
|
drop(constraint(:comments, "comments_in_reply_to_comment_id_fkey"))
|
|
|
|
drop(constraint(:comments, "comments_origin_comment_id_fkey"))
|
2018-11-08 17:57:10 +01:00
|
|
|
|
|
|
|
alter table(:comments) do
|
2019-11-15 18:36:47 +01:00
|
|
|
modify(:in_reply_to_comment_id, references(:comments, on_delete: :nothing))
|
|
|
|
modify(:origin_comment_id, references(:comments, on_delete: :delete_all))
|
2018-11-08 17:57:10 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|