mobilizon.chapril.org-mobil.../priv/repo/migrations/20190712125833_create_reports.exs
Thomas Citharel aef841e192 Introduce backend for reports
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2019-07-23 13:49:22 +02:00

34 lines
1.0 KiB
Elixir

defmodule Mobilizon.Repo.Migrations.CreateReports do
use Ecto.Migration
alias Mobilizon.Reports.ReportStateEnum
def up do
ReportStateEnum.create_type()
create table(:reports) do
add(:content, :string)
add(:status, ReportStateEnum.type(), default: "open", null: false)
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))
ReportStateEnum.drop_type()
end
end