From 2b126589780eaf4d64c7273ae05c2ebc904cddcf Mon Sep 17 00:00:00 2001 From: Martin Brennan Date: Thu, 18 Feb 2021 13:49:39 +1000 Subject: [PATCH] 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 --- config/settings.yml | 2 ++ ...2053_solved_fix_high_auto_close_topic_hours.rb | 15 +++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 db/migrate/20210218022053_solved_fix_high_auto_close_topic_hours.rb diff --git a/config/settings.yml b/config/settings.yml index c317001..8888a8b 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -16,6 +16,8 @@ plugins: client: false solved_topics_auto_close_hours: default: 0 + min: 0 + max: 175200 # 20 years show_filter_by_solved_status: default: false client: true diff --git a/db/migrate/20210218022053_solved_fix_high_auto_close_topic_hours.rb b/db/migrate/20210218022053_solved_fix_high_auto_close_topic_hours.rb new file mode 100644 index 0000000..199e014 --- /dev/null +++ b/db/migrate/20210218022053_solved_fix_high_auto_close_topic_hours.rb @@ -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