This repository has been archived on 2024-07-31. You can view files and clone it, but cannot push or open issues or pull requests.
2023-07-12 03:47:08 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-01-17 03:41:33 -05:00
|
|
|
class AddCategoryToReports < ActiveRecord::Migration[6.1]
|
|
|
|
disable_ddl_transaction!
|
|
|
|
|
|
|
|
def up
|
2023-11-06 11:15:48 -05:00
|
|
|
safety_assured do
|
2024-01-10 05:35:06 -05:00
|
|
|
add_column :reports, :category, :int, default: 0, null: false
|
2023-11-06 11:15:48 -05:00
|
|
|
change_table(:reports, bulk: true) do |t|
|
|
|
|
t.column :action_taken_at, :datetime
|
|
|
|
t.column :rule_ids, :bigint, array: true
|
|
|
|
end
|
|
|
|
execute 'UPDATE reports SET action_taken_at = updated_at WHERE action_taken = TRUE'
|
|
|
|
end
|
2022-01-17 03:41:33 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
2023-11-06 11:15:48 -05:00
|
|
|
safety_assured do
|
|
|
|
execute 'UPDATE reports SET action_taken = TRUE WHERE action_taken_at IS NOT NULL'
|
|
|
|
remove_column :reports, :category
|
|
|
|
change_table(:reports, bulk: true) do |t|
|
|
|
|
t.column :action_taken_at, :datetime
|
|
|
|
t.column :rule_ids, :bigint, array: true
|
|
|
|
end
|
|
|
|
end
|
2022-01-17 03:41:33 -05:00
|
|
|
end
|
|
|
|
end
|