mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-02 11:59:17 -05:00
810a069cfd
Since I18n has a DB backend now, I've introduced a helper we can use to skip overrides in certain situations. Otherwise migration from empty databases was broken.
18 lines
653 B
Ruby
18 lines
653 B
Ruby
class MigrateAutoClosePosts < ActiveRecord::Migration
|
|
def up
|
|
I18n.backend.overrides_disabled do
|
|
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
|
|
end
|