fixed migration template - reportable - Fork of reportable required by WarVox, from hdm/reportable.
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) commit 9b3e0fbf0b0e4f88f328442a701097b7b4a9b81b
(DIR) parent 543bb388afda3d3d580d4e18e86d005a5529f2e4
(HTM) Author: Marco Otte-Witte <marco.otte-witte@simplabs.com>
Date: Wed, 14 Jan 2009 00:00:17 +0800
fixed migration template
Signed-off-by: Marco Otte-Witte <marco.otte-witte@simplabs.com>
Diffstat:
M generators/reports_as_sparkline_mi… | 51 ++++++++++++++++++-------------
1 file changed, 30 insertions(+), 21 deletions(-)
---
(DIR) diff --git a/generators/reports_as_sparkline_migration/templates/migration.erb b/generators/reports_as_sparkline_migration/templates/migration.erb
@@ -1,27 +1,36 @@
class <%= class_name %> < ActiveRecord::Migration
- create_table :report_caches, :force => true do |t|
- t.string :model_name, :null => false
- t.string :report_name, :null => false
- t.string :grouping, :null => false
- t.string :aggregation, :null => false
- t.float :value, :null => false, :default => 0
- t.datetime :reporting_period, :null => false
+ def self.up
+ create_table :report_caches, :force => true do |t|
+ t.string :model_name, :null => false
+ t.string :report_name, :null => false
+ t.string :grouping, :null => false
+ t.string :aggregation, :null => false
+ t.float :value, :null => false, :default => 0
+ t.datetime :reporting_period, :null => false
- t.timestamps
+ t.timestamps
+ end
+ add_index :report_caches, [
+ :model_name,
+ :report_name,
+ :grouping,
+ :aggregation
+ ], :name => :name_model_grouping_agregation
+ add_index :report_caches, [
+ :model_name,
+ :report_name,
+ :grouping,
+ :aggregation,
+ :reporting_period
+ ], :unique => true, :name => :name_model_grouping_aggregation_period
+ end
+
+ def self.down
+ remove_index :name_model_grouping_agregation
+ remove_index :name_model_grouping_aggregation_period
+
+ drop_table :report_caches
end
- add_index :report_caches, [
- :model_name,
- :report_name,
- :grouping,
- :aggregation
- ], :name => 'name_model_grouping_agregation'
- add_index :report_caches, [
- :model_name,
- :report_name,
- :grouping,
- :aggregation,
- :reporting_period
- ], :unique => true, :name => 'name_model_grouping_aggregation_period'
end