Sha256: 5c753543fb9d7419f2c249035bf21c2ac9b84dd3ee40e99d55f78d5ae7f86d5f

Contents?: true

Size: 1.22 KB

Versions: 5

Compression:

Stored size: 1.22 KB

Contents

class CreateReportableCache < ActiveRecord::Migration

  def self.up
    create_table :reportable_cache, :force => true do |t|
      t.string   :model_name,       :null => false, :limit => 100
      t.string   :report_name,      :null => false, :limit => 100
      t.string   :grouping,         :null => false, :limit => 10
      t.string   :aggregation,      :null => false, :limit => 10
      t.string   :conditions,       :null => false, :limit => 100
      t.float    :value,            :null => false,                :default => 0
      t.datetime :reporting_period, :null => false

      t.timestamps
    end

    add_index :reportable_cache, [
      :model_name,
      :report_name,
      :grouping,
      :aggregation,
      :conditions
    ], :name => :name_model_grouping_agregation
    add_index :reportable_cache, [
      :model_name,
      :report_name,
      :grouping,
      :aggregation,
      :conditions,
      :reporting_period
    ], :unique => true, :name => :name_model_grouping_aggregation_period
  end

  def self.down
    remove_index :reportable_cache, :name => :name_model_grouping_agregation
    remove_index :reportable_cache, :name => :name_model_grouping_aggregation_period

    drop_table :reportable_cache
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
reportable-1.3.1 generators/reportable_migration/templates/migration.rb
reportable-1.3.0 generators/reportable_migration/templates/migration.rb
reportable-1.2.0 generators/reportable_migration/templates/migration.rb
reportable-1.1.2 generators/reportable_migration/templates/migration.rb
reportable-1.1.0 generators/reportable_migration/templates/migration.rb