FIX: Add min/max values for auto close hours (#121)

* Also add migration to cap current site settings for
solved_topics_auto_close_hours
  to the max of 175000 if they are too high
This commit is contained in:
Martin Brennan 2021-02-18 13:49:39 +10:00 committed by GitHub
parent 5c5b63e822
commit 2b12658978
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -16,6 +16,8 @@ plugins:
client: false client: false
solved_topics_auto_close_hours: solved_topics_auto_close_hours:
default: 0 default: 0
min: 0
max: 175200 # 20 years
show_filter_by_solved_status: show_filter_by_solved_status:
default: false default: false
client: true client: true

View File

@ -0,0 +1,15 @@
# frozen_string_literal: true
class SolvedFixHighAutoCloseTopicHours < ActiveRecord::Migration[6.0]
def up
execute <<-SQL
UPDATE site_settings
SET value = '175000'
WHERE name = 'solved_topics_auto_close_hours'
AND CAST(value AS INT) > 175000
SQL
end
def down
raise ActiveRecord::IrreversibleMigration
end
end