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

22 lines
737 B
Ruby
Raw Normal View History

# frozen_string_literal:true
class MigratePlanStats < ActiveRecord::Migration[4.2]
2016-03-23 18:39:41 +01:00
def up
index = StatisticIndex.where(es_type_key: 'subscription').first
return unless index
2016-03-23 18:39:41 +01:00
StatisticType.where(statistic_index_id: index.id).destroy_all
Plan.all.each(&:create_statistic_type)
2016-03-23 18:39:41 +01:00
end
def down
index = StatisticIndex.where(es_type_key: 'subscription').first
return unless index
2016-03-23 18:39:41 +01:00
StatisticType.where(statistic_index_id: index.id).destroy_all
StatisticType.create!(statistic_index_id: index.id, key: 'month', label: 'Abonnements mensuels', graph: true, simple: true)
StatisticType.create!(statistic_index_id: index.id, key: 'year', label: 'Abonnements annuels', graph: true, simple: true)
2016-03-23 18:39:41 +01:00
end
end