Class: CreatePersistenceTables

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/persistence/templates/db/migrate/001_create_persistence_tables.rb

Class Method Summary collapse

Class Method Details

.downObject



25
26
27
28
# File 'lib/generators/persistence/templates/db/migrate/001_create_persistence_tables.rb', line 25

def self.down
  drop_table :calculations
  drop_table :terms
end

.upObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/generators/persistence/templates/db/migrate/001_create_persistence_tables.rb', line 2

def self.up
  create_table :calculations do |t|
    t.string  "profile_uid"
    t.string  "profile_item_uid"
    t.string  "calculation_type"

    t.timestamps
  end

  create_table :terms do |t|
    t.integer  "calculation_id"
    t.string  "label"
    t.string  "value"

    t.timestamps
  end

  add_index :calculations, :calculation_type
  add_index :calculations, :profile_item_uid
  add_index :terms, [:calculation_id, :label], :name => "calc_id_label_index"
  add_index :terms, [:label, :value, :calculation_id], :name => "label_name_calc_id_index"
end