aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--db/migrate/20170213135212_add_timestamps_to_some_models.rb14
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