Class: CreateAloeTables

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

Instance Method Summary collapse

Instance Method Details

#changeObject



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
# File 'lib/generators/aloe/templates/migration.rb', line 3

def change
  create_table :aloe_accounts do |t|
    t.string :name
    t.string :currency, limit: 3
    t.string :state
    t.text :configuration
    t.column :balance, :bigint, default: 0
    t.references :owner, polymorphic: true
    t.timestamps
  end

  add_index :aloe_accounts, [:owner_id, :owner_type]
  add_index :aloe_accounts, :status

  create_table :aloe_entries do |t|
    t.column :amount, :bigint
    t.references :account
    t.timestamps
  end

  add_index :aloe_entries, :account_id

  create_table :aloe_transactions do |t|
    t.string :uuid
    t.string :category
    t.string :code
    t.text :description
    t.text :details
    t.references :credit_entry
    t.references :debit_entry
    t.references :adjustment_transaction
    t.timestamps
  end

  add_index :aloe_transactions, :uuid
  add_index :aloe_transactions, :credit_entry_id
  add_index :aloe_transactions, :debit_entry_id
  add_index :aloe_transactions, :adjustment_transaction_id
  add_index :aloe_transactions, :category
end