1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00

fix migration rollback

This commit is contained in:
Sylvain 2016-11-23 11:44:48 +01:00
parent 63a3bcf19a
commit 012a6b63c8

View File

@ -1,5 +1,5 @@
class InsertCustomAggregations < ActiveRecord::Migration class InsertCustomAggregations < ActiveRecord::Migration
def change def up
# available reservations hours for machines # available reservations hours for machines
machine = StatisticIndex.find_by_es_type_key('machine') machine = StatisticIndex.find_by_es_type_key('machine')
machine_hours = StatisticType.find_by(key: 'hour', statistic_index_id: machine.id) machine_hours = StatisticType.find_by(key: 'hour', statistic_index_id: machine.id)
@ -26,4 +26,17 @@ class InsertCustomAggregations < ActiveRecord::Migration
}) })
available_tickets.save! available_tickets.save!
end 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 end