2019-07-23 13:49:22 +02:00
|
|
|
defmodule Mobilizon.Repo.Migrations.CreateReports do
|
|
|
|
use Ecto.Migration
|
2019-09-07 02:38:13 +02:00
|
|
|
alias Mobilizon.Reports.ReportStatus
|
2019-07-23 13:49:22 +02:00
|
|
|
|
|
|
|
def up do
|
2019-09-07 02:38:13 +02:00
|
|
|
ReportStatus.create_type()
|
2019-07-23 13:49:22 +02:00
|
|
|
|
|
|
|
create table(:reports) do
|
|
|
|
add(:content, :string)
|
2019-09-07 02:38:13 +02:00
|
|
|
add(:status, ReportStatus.type(), default: "open", null: false)
|
2019-07-23 13:49:22 +02:00
|
|
|
add(:uri, :string, null: false)
|
|
|
|
|
|
|
|
add(:reported_id, references(:actors, on_delete: :delete_all), null: false)
|
|
|
|
add(:reporter_id, references(:actors, on_delete: :delete_all), null: false)
|
|
|
|
add(:manager_id, references(:actors, on_delete: :delete_all), null: true)
|
|
|
|
add(:event_id, references(:events, on_delete: :delete_all), null: true)
|
|
|
|
|
|
|
|
timestamps()
|
|
|
|
end
|
|
|
|
|
|
|
|
create table(:reports_comments, primary_key: false) do
|
|
|
|
add(:report_id, references(:reports, on_delete: :delete_all), null: false)
|
|
|
|
add(:comment_id, references(:comments, on_delete: :delete_all), null: false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def down do
|
|
|
|
drop(table(:reports_comments))
|
|
|
|
drop(table(:reports))
|
|
|
|
|
2019-09-07 02:38:13 +02:00
|
|
|
ReportStatus.drop_type()
|
2019-07-23 13:49:22 +02:00
|
|
|
end
|
|
|
|
end
|