about summary refs log tree commit diff
path: root/db/migrate
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate')
-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
4 files changed, 55 insertions, 0 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