From 012a6b63c8708e198802cdde9a7389d6b345bf9a Mon Sep 17 00:00:00 2001 From: Sylvain Date: Wed, 23 Nov 2016 11:44:48 +0100 Subject: [PATCH] fix migration rollback --- .../20160906145713_insert_custom_aggregations.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/db/migrate/20160906145713_insert_custom_aggregations.rb b/db/migrate/20160906145713_insert_custom_aggregations.rb index 90c95e456..1b23072c1 100644 --- a/db/migrate/20160906145713_insert_custom_aggregations.rb +++ b/db/migrate/20160906145713_insert_custom_aggregations.rb @@ -1,5 +1,5 @@ class InsertCustomAggregations < ActiveRecord::Migration - def change + def up # available reservations hours for machines machine = StatisticIndex.find_by_es_type_key('machine') machine_hours = StatisticType.find_by(key: 'hour', statistic_index_id: machine.id) @@ -26,4 +26,17 @@ class InsertCustomAggregations < ActiveRecord::Migration }) available_tickets.save! end + + def down + + machine = StatisticIndex.find_by_es_type_key('machine') + machine_hours = StatisticType.find_by(key: 'hour', statistic_index_id: machine.id) + + StatisticCustomAggregation.where(field: 'available_hours', statistic_type_id: machine_hours.id).first.destroy! + + training = StatisticIndex.find_by_es_type_key('training') + training_bookings = StatisticType.find_by(key: 'booking', statistic_index_id: training.id) + + StatisticCustomAggregation.where(field: 'available_tickets', statistic_type_id: training_bookings.id).first.destroy! + end end