Class: CreatePlutusTables

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

Class Method Summary (collapse)

Class Method Details

+ (Object) down



29
30
31
32
# File 'lib/generators/plutus/templates/migration.rb', line 29

def self.down
  drop_table :accounts
  drop_table :transactions
end

+ (Object) up



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

def self.up
  create_table :accounts do |t|
    t.string :name
    t.string :type
    t.boolean :contra

    t.timestamps
  end
  
  add_index :accounts, [:name, :type]
 
  create_table :transactions do |t|
    t.string :description
    t.integer :credit_account_id
    t.integer :debit_account_id
    t.decimal :amount, :precision => 20, :scale => 10
    t.integer :commercial_document_id
    t.string :commercial_document_type

    t.timestamps
  end

  add_index :transactions, :credit_account_id
  add_index :transactions, :debit_account_id
  add_index :transactions, [:commercial_document_id, :commercial_document_type], :name => "index_transactions_on_commercial_doc"
end