Class: DeathAndTaxesMigration

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/death_and_taxes/migration/templates/active_record/migration.rb

Class Method Summary collapse

Class Method Details

.downObject



28
29
30
31
# File 'lib/generators/death_and_taxes/migration/templates/active_record/migration.rb', line 28

def self.down
  drop_table :taxations
  drop_table :taxes
end

.upObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/generators/death_and_taxes/migration/templates/active_record/migration.rb', line 2

def self.up
  create_table :taxations do |t|
    t.references :taxable, :polymorphic => true
    t.integer :amount
    t.float :percentage
    t.string :name
    t.string :account_number
    
    t.timestamps
  end
  
  create_table :taxes do |t|
    t.references :taxer, :polymorphic => true
    t.float :percentage
    t.string :name
    t.string :account_number
    t.integer :apply_on_tax
    
    t.timestamps
  end
  
  add_index :taxations, [:taxable_id, :taxable_type]
  add_index :taxes, [:taxer_id, :taxer_type]
  add_index :taxes, :apply_on_tax
end