From 6a404cdbe9534f688339d002b7ded453180f9633 Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Tue, 11 Oct 2016 03:55:49 +0300 Subject: [PATCH] Add data consistency migrations --- ..._minimal_and_maximal_times_for_all_event_types.rb | 12 ++++++++++++ ...20161011005420_add_descriptions_for_all_events.rb | 11 +++++++++++ 2 files changed, 23 insertions(+) create mode 100644 db/migrate/20161011005219_set_minimal_and_maximal_times_for_all_event_types.rb create mode 100644 db/migrate/20161011005420_add_descriptions_for_all_events.rb diff --git a/db/migrate/20161011005219_set_minimal_and_maximal_times_for_all_event_types.rb b/db/migrate/20161011005219_set_minimal_and_maximal_times_for_all_event_types.rb new file mode 100644 index 0000000..5bf1185 --- /dev/null +++ b/db/migrate/20161011005219_set_minimal_and_maximal_times_for_all_event_types.rb @@ -0,0 +1,12 @@ +class EventType < ActiveRecord::Base +end + +class SetMinimalAndMaximalTimesForAllEventTypes < ActiveRecord::Migration + def up + EventType.where(minimum_length: nil).update_all(minimum_length: 0) + EventType.where(maximum_length: nil).update_all(maximum_length: 240) + end + + def down + end +end diff --git a/db/migrate/20161011005420_add_descriptions_for_all_events.rb b/db/migrate/20161011005420_add_descriptions_for_all_events.rb new file mode 100644 index 0000000..a8c018f --- /dev/null +++ b/db/migrate/20161011005420_add_descriptions_for_all_events.rb @@ -0,0 +1,11 @@ +class Event < ActiveRecord::Base +end + +class AddDescriptionsForAllEvents < ActiveRecord::Migration + def up + Event.where(description: [nil, '']).update_all(description: 'n/a') + end + + def down + end +end