-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from nutso/develop
Develop
- Loading branch information
Showing
11 changed files
with
172 additions
and
33 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
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
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
29 changes: 29 additions & 0 deletions
29
db/migrate/002_standardize_recurrence_units_nonlocalized.rb
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Previous to this migration, the value for recurring_tasks.interval_units | ||
# was pulled from the localization file. | ||
# This made the values more user-friendly when looking at the database directly | ||
# however caused issues when the text changed, or locale changed. | ||
# Here we are switching to just flags to denote the type of unit instead of text. | ||
class StandardizeRecurrenceUnitsNonlocalized < ActiveRecord::Migration | ||
def up | ||
RecurringTask.all.each do |rt| | ||
begin | ||
logger.info "Migrating task ##{rt.id} from #{rt.interval_unit}" | ||
rt.interval_unit = RecurringTask.get_interval_from_localized_name(rt.interval_unit) | ||
rt.save!(:validate => false) | ||
rescue => e | ||
msg = "Migration for recurrence FAILED. ##{rt.id} from #{rt.interval_unit} FAILED. You will need to update this manually. Error: #{e}" # TODO localize | ||
logger.error msg | ||
say msg # also display to user | ||
end | ||
end | ||
end | ||
|
||
# There is no rolling back - this is a change to the DATA in the database, | ||
# not to the structure itself. | ||
# There is no guarantee that the current localized translation was the value | ||
# previously in the database. | ||
def down | ||
# say "ActiveRecord::IrreversibleMigration" | ||
raise ActiveRecord::IrreversibleMigration | ||
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