20211231080958_add_category_to_reports.rb 774 B

123456789101112131415161718192021
  1. require Rails.root.join('lib', 'mastodon', 'migration_helpers')
  2. class AddCategoryToReports < ActiveRecord::Migration[6.1]
  3. include Mastodon::MigrationHelpers
  4. disable_ddl_transaction!
  5. def up
  6. safety_assured { add_column_with_default :reports, :category, :int, default: 0, allow_null: false }
  7. add_column :reports, :action_taken_at, :datetime
  8. add_column :reports, :rule_ids, :bigint, array: true
  9. safety_assured { execute 'UPDATE reports SET action_taken_at = updated_at WHERE action_taken = TRUE' }
  10. end
  11. def down
  12. safety_assured { execute 'UPDATE reports SET action_taken = TRUE WHERE action_taken_at IS NOT NULL' }
  13. remove_column :reports, :category
  14. remove_column :reports, :action_taken_at
  15. remove_column :reports, :rule_ids
  16. end
  17. end