diff options
| author | jpl | 2017-02-14 17:12:46 +0100 |
|---|---|---|
| committer | jpl | 2017-02-14 17:12:46 +0100 |
| commit | 5fbfc7f87bcae3fdccedbbbf8cb5134fd592ed50 (patch) | |
| tree | 308ece560a13fb0f41469eebd4e52b7ee3265fec /db/migrate | |
| parent | a9b42b07109ba40045e06e5e9a6c7564004d574c (diff) | |
| download | chouette-core-5fbfc7f87bcae3fdccedbbbf8cb5134fd592ed50.tar.bz2 | |
Fix stuff, featuring Alban Peigner
Diffstat (limited to 'db/migrate')
| -rw-r--r-- | db/migrate/20170213135212_add_timestamps_to_some_models.rb | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/db/migrate/20170213135212_add_timestamps_to_some_models.rb b/db/migrate/20170213135212_add_timestamps_to_some_models.rb index 1502975fe..c9fdb1d54 100644 --- a/db/migrate/20170213135212_add_timestamps_to_some_models.rb +++ b/db/migrate/20170213135212_add_timestamps_to_some_models.rb @@ -1,14 +1,21 @@ class AddTimestampsToSomeModels < ActiveRecord::Migration - def change + def up 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) + unless column_exists?(table, :created_at) 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) + + if column_exists?(table, :creation_time) + execute "update #{table} set created_at = creation_time" + remove_column table, :creation_time + end end end + + def down + + end end |
