Sha256: df86dec89aaf8b784aca4b6c48d5b9e178176ff90839e28f6d9160261415a90f

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

class CreateCredereTables < ActiveRecord::Migration[5.2]
  def self.up
    create_table :credere_accounts do |t|
      t.string :name
      t.string :type
      t.boolean :contra, default: false

      t.timestamps
    end
    add_index :credere_accounts, [:name, :type]

    create_table :credere_entries do |t|
      t.string :description
      t.date :date
      t.integer :commercial_document_id
      t.string :commercial_document_type

      t.timestamps
    end
    add_index :credere_entries, :date
    add_index :credere_entries, [:commercial_document_id, :commercial_document_type], :name => "index_entries_on_commercial_doc"

    create_table :credere_amounts do |t|
      t.string :type
      t.references :account
      t.references :entry
      t.decimal :amount, :precision => 20, :scale => 10
    end
    add_index :credere_amounts, :type
    add_index :credere_amounts, [:account_id, :entry_id]
    add_index :credere_amounts, [:entry_id, :account_id]
  end

  def self.down
    drop_table :credere_accounts
    drop_table :credere_entries
    drop_table :credere_amounts
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
credere-0.10.3 lib/generators/credere/templates/migration.rb
credere-0.10.2 lib/generators/credere/templates/migration.rb
credere-0.10.1 lib/generators/credere/templates/migration.rb