Class: KeeprMigration

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

Class Method Summary collapse

Class Method Details

.downObject



56
57
58
59
60
61
62
63
# File 'lib/generators/keepr/migration/templates/migration.rb', line 56

def self.down
  drop_table Keepr::Posting
  drop_table Keepr::Journal
  drop_table Keepr::Account
  drop_table Keepr::CostCenter
  drop_table Keepr::Tax
  drop_table Keepr::Group
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/generators/keepr/migration/templates/migration.rb', line 2

def self.up
  create_table Keepr::Group, force: true do |t|
    t.integer    :target, :null => false
    t.string     :number
    t.string     :name, :null => false
    t.boolean    :is_result, :null => false, :default => false
    t.string     :ancestry, :index => true
  end

  create_table Keepr::Tax, force: true do |t|
    t.string     :name, :null => false
    t.string     :description
    t.decimal    :value, :precision => 8, :scale => 2, :null => false
    t.references :keepr_account, :null => false, :index => true
  end

  create_table Keepr::CostCenter, force: true do |t|
    t.string     :number, :null => false
    t.string     :name, :null => false
    t.text       :note
  end

  create_table Keepr::Account, force: true do |t|
    t.integer    :number, :null => false, :index => true
    t.string     :ancestry, :index => true
    t.string     :name, :null => false
    t.integer    :kind, :null => false
    t.references :keepr_group, :index => true
    t.references :accountable, :polymorphic => true, :index => true
    t.references :keepr_tax, :index => true
    t.datetime   :created_at
    t.datetime   :updated_at
  end

  create_table Keepr::Journal, force: true do |t|
    t.string   :number
    t.date     :date, :null => false, :index => true
    t.string   :subject
    t.references :accountable, :polymorphic => true, :index => true
    t.text     :note
    t.boolean  :permanent, :null => false, :default => false
    t.datetime :created_at
    t.datetime :updated_at
  end

  create_table Keepr::Posting, force: true do |t|
    t.references :keepr_account, :null => false, :index => true
    t.references :keepr_journal, :null => false, :index => true
    t.decimal    :amount, :precision => 8, :scale => 2, :null => false
    t.references :keepr_cost_center, :index => true
    t.references :accountable, :polymorphic => true, :index => true
  end
end