Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX: Couldn't migrate database from nothing due to I18n
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.
- Loading branch information
Showing
7 changed files
with
44 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
class FixTosName < ActiveRecord::Migration | ||
def up | ||
execute ActiveRecord::Base.sql_fragment('UPDATE user_fields SET name = ? WHERE name = ?', I18n.t('terms_of_service.title'), I18n.t("terms_of_service.signup_form_message")) | ||
I18n.backend.overrides_disabled do | ||
execute ActiveRecord::Base.sql_fragment('UPDATE user_fields SET name = ? WHERE name = ?', I18n.t('terms_of_service.title'), I18n.t("terms_of_service.signup_form_message")) | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
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 | ||
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 << ")" | ||
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 | ||
execute sql | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters