diff options
| author | Vlatka Pavisic | 2017-02-14 13:38:29 +0100 |
|---|---|---|
| committer | Xinhui | 2017-02-20 11:52:06 +0100 |
| commit | 84e433dbdbd457c922725ea54cd703ed28da7ab6 (patch) | |
| tree | 61feff388aab7438ec66669dbb240b141b3c7c18 /db | |
| parent | 037308d9456132a8cc5cd3415c2bfe89f7e2b467 (diff) | |
| download | chouette-core-84e433dbdbd457c922725ea54cd703ed28da7ab6.tar.bz2 | |
Refs #2596 : Fix migration
Diffstat (limited to 'db')
| -rw-r--r-- | db/migrate/20170213135212_add_timestamps_to_some_models.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/db/migrate/20170213135212_add_timestamps_to_some_models.rb b/db/migrate/20170213135212_add_timestamps_to_some_models.rb new file mode 100644 index 000000000..1502975fe --- /dev/null +++ b/db/migrate/20170213135212_add_timestamps_to_some_models.rb @@ -0,0 +1,14 @@ +class AddTimestampsToSomeModels < ActiveRecord::Migration + def change + models = %i(vehicle_journeys timebands time_tables stop_points stop_areas routing_constraint_zones routes route_sections pt_links networks lines + journey_patterns group_of_lines connection_links companies access_points access_links) + + models.each do |table| + if !column_exists?(table, :created_at) && column_exists?(table, :creation_time) + add_timestamps table + Object.const_get("Chouette::#{table.to_s.classify}").update_all 'created_at = creation_time' + end + remove_column table, :creation_time if column_exists?(table, :creation_time) + end + end +end |
