Merge pull request #780 from opf/fix/none_type_migration_for_timelines_options_3528

[FIX] 'none' type migration for timelines options 3528
pull/776/merge
cratz 11 years ago
commit 2840f7c782
  1. 2
      db/migrate/20131024140048_migrate_timelines_options.rb
  2. 3
      doc/CHANGELOG.md
  3. 15
      lib/tasks/fix_missing_none_type_in_timelines_config.rake

@ -154,7 +154,7 @@ class MigrateTimelinesOptions < ActiveRecord::Migration
end
def pe_type_id_map
@pe_type_id_map ||= pe_types_ids_with_new_ids.each_with_object({}) do |r, h|
@pe_type_id_map ||= pe_types_ids_with_new_ids.each_with_object({ -1 => 0 }) do |r, h|
h[r['id']] = r['new_id']
end
end

@ -29,9 +29,10 @@ See doc/COPYRIGHT.rdoc for more details.
# Changelog
* `#3528` [Data Migration] Type 'none' is not migrated properly in Timelines
* `#3539` [Work package tracking] Modul view of work packages is too broad
* Fixed workflow copy view
* Add redirect from /wp to /work_packages for less typing
* `#3539` [Work package tracking] Modul view of work packages is too broad
## 3.0.0pre41

@ -33,6 +33,7 @@ namespace :migrations do
private
PE_TYPE_KEY = 'planning_element_types'
PE_TIME_TYPE_KEY = 'planning_element_time_types'
# We create the migration class dynamically because rake would try to
# execute the migration on 'rake db:migrate' otherwise.
@ -63,14 +64,16 @@ namespace :migrations do
end
def add_none_type_id_to_options(options)
pe_types = []
pe_types = options[PE_TYPE_KEY] if options.has_key? PE_TYPE_KEY
[PE_TYPE_KEY, PE_TIME_TYPE_KEY].each do |key|
pe_types = []
pe_types = options[key] if options.has_key? key
# Compare strings instead of plain integers because timelines
# options may contain strings or integers.
pe_types.map! { |t| (t.to_s == '0') ? @standard_type.id : t }
# Compare strings instead of plain integers because timelines
# options may contain strings or integers.
pe_types.map! { |t| (t.to_s == '0') ? @standard_type.id.to_s : t.to_s }
options[PE_TYPE_KEY] = pe_types
options[key] = pe_types
end
options
end

Loading…
Cancel
Save