mirror of
https://github.com/discourse/discourse.git
synced 2024-12-30 06:33:50 +08:00
4b1e017722
The mistake was made when flags were moved to the database. The `notify_moderators` (something else) flag should be the last position on the list. This commit contains 3 changes: - update fixtures order; - remove position and enable from fixtures (they can be overridden by admin and we don't want seed to restore them); - migration to fix data if the order was not changed by admin.
26 lines
856 B
Ruby
26 lines
856 B
Ruby
# frozen_string_literal: true
|
|
|
|
class ReorderFlags < ActiveRecord::Migration[7.0]
|
|
def up
|
|
current_order = DB.query(<<~SQL)
|
|
SELECT name FROM flags
|
|
WHERE score_type IS FALSE
|
|
ORDER BY position ASC
|
|
SQL
|
|
|
|
if current_order.map(&:name) ==
|
|
%w[notify_user notify_moderators off_topic inappropriate spam illegal]
|
|
execute "UPDATE flags SET position = 0 WHERE name = 'notify_user'"
|
|
execute "UPDATE flags SET position = 1 WHERE name = 'off_topic'"
|
|
execute "UPDATE flags SET position = 2 WHERE name = 'inappropriate'"
|
|
execute "UPDATE flags SET position = 3 WHERE name = 'spam'"
|
|
execute "UPDATE flags SET position = 4 WHERE name = 'illegal'"
|
|
execute "UPDATE flags SET position = 5 WHERE name = 'notify_moderators'"
|
|
end
|
|
end
|
|
|
|
def down
|
|
raise ActiveRecord::IrreversibleMigration
|
|
end
|
|
end
|