Introduce backend for reports

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2019-07-23 13:49:22 +02:00
parent 33a8da4570
commit aef841e192
36 changed files with 2028 additions and 36 deletions

View File

@@ -0,0 +1,33 @@
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

View File

@@ -0,0 +1,13 @@
defmodule Mobilizon.Repo.Migrations.CreateReportNotes do
use Ecto.Migration
def change do
create table(:report_notes) do
add(:content, :string, null: false)
add(:moderator_id, references(:actors, on_delete: :delete_all), null: false)
add(:report_id, references(:reports, on_delete: :delete_all), null: false)
timestamps()
end
end
end

View File

@@ -0,0 +1,15 @@
defmodule Mobilizon.Repo.Migrations.CreateAdminActionLogs do
use Ecto.Migration
def change do
create table(:admin_action_logs) do
add(:action, :string, null: false)
add(:target_type, :string, null: false)
add(:target_id, :int, null: false)
add(:changes, :map)
add(:actor_id, references(:actors, on_delete: :nilify_all), null: false)
timestamps()
end
end
end