mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 03:06:53 +08:00
Migrate auto closed topics too
This commit is contained in:
16
db/migrate/20150729150523_migrate_auto_close_posts.rb
Normal file
16
db/migrate/20150729150523_migrate_auto_close_posts.rb
Normal file
@ -0,0 +1,16 @@
|
||||
class MigrateAutoClosePosts < ActiveRecord::Migration
|
||||
def up
|
||||
strings = []
|
||||
%w(days hours lastpost_days lastpost_hours lastpost_minutes).map do |k|
|
||||
strings << I18n.t("topic_statuses.autoclosed_enabled_#{k}.one")
|
||||
strings << I18n.t("topic_statuses.autoclosed_enabled_#{k}.other").sub("%{count}", "\\d+")
|
||||
end
|
||||
|
||||
sql = "UPDATE posts SET action_code = 'autoclosed.enabled', post_type = 3 "
|
||||
sql << "WHERE post_type = 2 AND ("
|
||||
sql << strings.map {|s| "raw ~* #{ActiveRecord::Base.connection.quote(s)}" }.join(' OR ')
|
||||
sql << ")"
|
||||
|
||||
execute sql
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user