Sha256: 93a73626976fb2d9fea76a8b9176efd2e40921541125932b6e1976d1c0f1f93b

Contents?: true

Size: 574 Bytes

Versions: 1

Compression:

Stored size: 574 Bytes

Contents

# frozen_string_literal: true

class CreateLedgerAccounts < ActiveRecord::Migration[6.1]
  def change
    create_table <%= prefixed_table_name(:accounts) %> do |t|
      t.string     :type, null: false
      t.belongs_to :owner, null: true, polymorphic: true
      t.string     :name, null: false
      t.integer    :coefficient, null: false
      t.timestamps default: -> { 'NOW()' }

      t.check_constraint 'coefficient IN (-1, +1)'

      t.index %i[owner_type owner_id name], unique: true
      t.index :name, unique: true, where: 'owner_id IS NULL'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
generalis-0.1.0 lib/generators/generalis/templates/create_ledger_accounts.rb.erb