about summary refs log tree commit diff
path: root/db
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-01-17 10:45:25 +0100
committerClaire <claire.github-309c@sitedethib.com>2022-01-17 10:45:25 +0100
commitb3bf32a21e4dfc43737f50f15d3f258c16d0cf83 (patch)
tree37daa7d7725d3676115eea2c4d4a215bdd95c06d /db
parent430d4427916b44e6a7c16db1899dfef2eec140fc (diff)
parent14f436c457560862fafabd753eb314c8b8a8e674 (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Conflicts:
- `app/views/admin/reports/show.html.haml`:
  Conflicts due to glitch-soc's theming system.
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20211231080958_add_category_to_reports.rb21
-rw-r--r--db/migrate/20220115125126_add_report_id_to_account_warnings.rb6
-rw-r--r--db/migrate/20220115125341_fix_account_warning_actions.rb21
-rw-r--r--db/migrate/20220116202951_add_deleted_at_index_on_statuses.rb7
-rw-r--r--db/post_migrate/20220109213908_remove_action_taken_from_reports.rb9
-rw-r--r--db/schema.rb10
6 files changed, 72 insertions, 2 deletions
diff --git a/db/migrate/20211231080958_add_category_to_reports.rb b/db/migrate/20211231080958_add_category_to_reports.rb
new file mode 100644
index 000000000..c2b495c63
--- /dev/null
+++ b/db/migrate/20211231080958_add_category_to_reports.rb
@@ -0,0 +1,21 @@
+require Rails.root.join('lib', 'mastodon', 'migration_helpers')
+
+class AddCategoryToReports < ActiveRecord::Migration[6.1]
+  include Mastodon::MigrationHelpers
+
+  disable_ddl_transaction!
+
+  def up
+    safety_assured { add_column_with_default :reports, :category, :int, default: 0, allow_null: false }
+    add_column :reports, :action_taken_at, :datetime
+    add_column :reports, :rule_ids, :bigint, array: true
+    safety_assured { execute 'UPDATE reports SET action_taken_at = updated_at WHERE action_taken = TRUE' }
+  end
+
+  def down
+    safety_assured { execute 'UPDATE reports SET action_taken = TRUE WHERE action_taken_at IS NOT NULL' }
+    remove_column :reports, :category
+    remove_column :reports, :action_taken_at
+    remove_column :reports, :rule_ids
+  end
+end
diff --git a/db/migrate/20220115125126_add_report_id_to_account_warnings.rb b/db/migrate/20220115125126_add_report_id_to_account_warnings.rb
new file mode 100644
index 000000000..a1c20c99e
--- /dev/null
+++ b/db/migrate/20220115125126_add_report_id_to_account_warnings.rb
@@ -0,0 +1,6 @@
+class AddReportIdToAccountWarnings < ActiveRecord::Migration[6.1]
+  def change
+    safety_assured { add_reference :account_warnings, :report, foreign_key: { on_delete: :cascade }, index: false }
+    add_column :account_warnings, :status_ids, :string, array: true
+  end
+end
diff --git a/db/migrate/20220115125341_fix_account_warning_actions.rb b/db/migrate/20220115125341_fix_account_warning_actions.rb
new file mode 100644
index 000000000..25cc17fd3
--- /dev/null
+++ b/db/migrate/20220115125341_fix_account_warning_actions.rb
@@ -0,0 +1,21 @@
+class FixAccountWarningActions < ActiveRecord::Migration[6.1]
+  disable_ddl_transaction!
+
+  def up
+    safety_assured do
+      execute 'UPDATE account_warnings SET action = 1000 WHERE action = 1'
+      execute 'UPDATE account_warnings SET action = 2000 WHERE action = 2'
+      execute 'UPDATE account_warnings SET action = 3000 WHERE action = 3'
+      execute 'UPDATE account_warnings SET action = 4000 WHERE action = 4'
+    end
+  end
+
+  def down
+    safety_assured do
+      execute 'UPDATE account_warnings SET action = 1 WHERE action = 1000'
+      execute 'UPDATE account_warnings SET action = 2 WHERE action = 2000'
+      execute 'UPDATE account_warnings SET action = 3 WHERE action = 3000'
+      execute 'UPDATE account_warnings SET action = 4 WHERE action = 4000'
+    end
+  end
+end
diff --git a/db/migrate/20220116202951_add_deleted_at_index_on_statuses.rb b/db/migrate/20220116202951_add_deleted_at_index_on_statuses.rb
new file mode 100644
index 000000000..dc3362552
--- /dev/null
+++ b/db/migrate/20220116202951_add_deleted_at_index_on_statuses.rb
@@ -0,0 +1,7 @@
+class AddDeletedAtIndexOnStatuses < ActiveRecord::Migration[6.1]
+  disable_ddl_transaction!
+
+  def change
+    add_index :statuses, :deleted_at, where: 'deleted_at IS NOT NULL', algorithm: :concurrently
+  end
+end
diff --git a/db/post_migrate/20220109213908_remove_action_taken_from_reports.rb b/db/post_migrate/20220109213908_remove_action_taken_from_reports.rb
new file mode 100644
index 000000000..73e6ad6f4
--- /dev/null
+++ b/db/post_migrate/20220109213908_remove_action_taken_from_reports.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class RemoveActionTakenFromReports < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def change
+    safety_assured { remove_column :reports, :action_taken, :boolean, default: false, null: false }
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index d357512b3..7b5a301ff 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
 #
 # It's strongly recommended that you check this file into your version control system.
 
-ActiveRecord::Schema.define(version: 2021_12_13_040746) do
+ActiveRecord::Schema.define(version: 2022_01_16_202951) do
 
   # These are extensions that must be enabled in order to support this database
   enable_extension "plpgsql"
@@ -133,6 +133,8 @@ ActiveRecord::Schema.define(version: 2021_12_13_040746) do
     t.text "text", default: "", null: false
     t.datetime "created_at", null: false
     t.datetime "updated_at", null: false
+    t.bigint "report_id"
+    t.string "status_ids", array: true
     t.index ["account_id"], name: "index_account_warnings_on_account_id"
     t.index ["target_account_id"], name: "index_account_warnings_on_target_account_id"
   end
@@ -747,7 +749,6 @@ ActiveRecord::Schema.define(version: 2021_12_13_040746) do
   create_table "reports", force: :cascade do |t|
     t.bigint "status_ids", default: [], null: false, array: true
     t.text "comment", default: "", null: false
-    t.boolean "action_taken", default: false, null: false
     t.datetime "created_at", null: false
     t.datetime "updated_at", null: false
     t.bigint "account_id", null: false
@@ -756,6 +757,9 @@ ActiveRecord::Schema.define(version: 2021_12_13_040746) do
     t.bigint "assigned_account_id"
     t.string "uri"
     t.boolean "forwarded"
+    t.integer "category", default: 0, null: false
+    t.datetime "action_taken_at"
+    t.bigint "rule_ids", array: true
     t.index ["account_id"], name: "index_reports_on_account_id"
     t.index ["target_account_id"], name: "index_reports_on_target_account_id"
   end
@@ -853,6 +857,7 @@ ActiveRecord::Schema.define(version: 2021_12_13_040746) do
     t.string "content_type"
     t.datetime "deleted_at"
     t.index ["account_id", "id", "visibility", "updated_at"], name: "index_statuses_20190820", order: { id: :desc }, where: "(deleted_at IS NULL)"
+    t.index ["deleted_at"], name: "index_statuses_on_deleted_at", where: "(deleted_at IS NOT NULL)"
     t.index ["id", "account_id"], name: "index_statuses_local_20190824", order: { id: :desc }, where: "((local OR (uri IS NULL)) AND (deleted_at IS NULL) AND (visibility = 0) AND (reblog_of_id IS NULL) AND ((NOT reply) OR (in_reply_to_account_id = account_id)))"
     t.index ["id", "account_id"], name: "index_statuses_public_20200119", order: { id: :desc }, where: "((deleted_at IS NULL) AND (visibility = 0) AND (reblog_of_id IS NULL) AND ((NOT reply) OR (in_reply_to_account_id = account_id)))"
     t.index ["in_reply_to_account_id"], name: "index_statuses_on_in_reply_to_account_id"
@@ -1010,6 +1015,7 @@ ActiveRecord::Schema.define(version: 2021_12_13_040746) do
   add_foreign_key "account_statuses_cleanup_policies", "accounts", on_delete: :cascade
   add_foreign_key "account_warnings", "accounts", column: "target_account_id", on_delete: :cascade
   add_foreign_key "account_warnings", "accounts", on_delete: :nullify
+  add_foreign_key "account_warnings", "reports", on_delete: :cascade
   add_foreign_key "accounts", "accounts", column: "moved_to_account_id", on_delete: :nullify
   add_foreign_key "admin_action_logs", "accounts", on_delete: :cascade
   add_foreign_key "announcement_mutes", "accounts", on_delete: :cascade