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
|
# File 'lib/generators/bookkeeping/templates/migration.rb', line 2
def self.up
create_table :bookkeeping_accounts do |t|
t.string :name
t.string :type
t.boolean :overdraft_enabled, null: false, default: :true
t.references :accountable, polymorphic: true
t.timestamps
end
add_index :bookkeeping_accounts, :accountable_id
add_index :bookkeeping_accounts, :accountable_type
create_table :bookkeeping_entries do |t|
t.string :description
t.references :transactionable, polymorphic: true
t.integer :rollback_entry_id
t.timestamps
end
add_index :bookkeeping_entries, :transactionable_id
add_index :bookkeeping_entries, :transactionable_type
create_table :bookkeeping_amounts do |t|
t.string :type
t.boolean :is_debit, default: true, null: false
t.integer :account_id
t.integer :entry_id
t.decimal :amount, precision: 20, scale: 2, default: 0
end
add_index :bookkeeping_amounts, :account_id
add_index :bookkeeping_amounts, :entry_id
end
|