DEV: Default num_auto_bump_daily to 0

This commit is contained in:
Ted Johansson 2023-03-10 16:51:31 +08:00
parent cda91aa1fe
commit 52a142ac63
No known key found for this signature in database
GPG Key ID: 2E801F82D9A4C6E9
3 changed files with 25 additions and 2 deletions

View File

@ -645,7 +645,7 @@ class Category < ActiveRecord::Base
.joins(:category_setting)
.where("category_settings.num_auto_bump_daily > 0")
.shuffle
.any? { |c| c.auto_bump_topic! }
.any?(&:auto_bump_topic!)
end
# will automatically bump a single topic

View File

@ -26,7 +26,7 @@ end
# category_id :bigint not null
# require_topic_approval :boolean
# require_reply_approval :boolean
# num_auto_bump_daily :integer
# num_auto_bump_daily :integer default(0)
# created_at :datetime not null
# updated_at :datetime not null
# auto_bump_cooldown_days :integer default(1)

View File

@ -0,0 +1,23 @@
# frozen_string_literal: true
class ChangeCategorySettingNumAutoBumpDailyDefault < ActiveRecord::Migration[7.0]
def up
change_column_default :category_settings, :num_auto_bump_daily, 0
execute(<<~SQL)
UPDATE category_settings
SET num_auto_bump_daily = 0
WHERE num_auto_bump_daily IS NULL;
SQL
end
def down
change_column_default :category_settings, :num_auto_bump_daily, nil
execute(<<~SQL)
UPDATE category_settings
SET num_auto_bump_daily = NULL
WHERE num_auto_bump_daily = 0;
SQL
end
end