2018-11-08 16:57:10 +00: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 13:18:52 +00:00
|
|
|
drop(constraint(:comments, "comments_in_reply_to_comment_id_fkey"))
|
|
|
|
drop(constraint(:comments, "comments_origin_comment_id_fkey"))
|
2018-11-08 16:57:10 +00:00
|
|
|
|
|
|
|
alter table(:comments) do
|
2019-02-22 13:18:52 +00:00
|
|
|
modify(:in_reply_to_comment_id, references(:comments, on_delete: :nothing))
|
|
|
|
modify(:origin_comment_id, references(:comments, on_delete: :nothing))
|
2018-11-08 16:57:10 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def down do
|
2019-02-22 13:18:52 +00:00
|
|
|
drop(constraint(:comments, "comments_in_reply_to_comment_id_fkey"))
|
|
|
|
drop(constraint(:comments, "comments_origin_comment_id_fkey"))
|
2018-11-08 16:57:10 +00:00
|
|
|
|
|
|
|
alter table(:comments) do
|
2019-11-15 17:36:47 +00: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 16:57:10 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|