Files
sx-fc/db/migrate/20170403161857_create_sale_items.rb

24 lines
1.3 KiB
Ruby
Executable File

class CreateSaleItems < ActiveRecord::Migration[5.1]
def change
create_table :sale_items, :id => false do |t|
t.string :sale_item_id, :limit => 16, :primary_key => true#custom primary key - to ensure consistence for cloud syncing
t.string :sale_id, foreign_key: true, :limit => 16, :index => true
t.string :product_code, :null => false
t.string :item_instance_code
t.string :product_name, :null => false
t.string :product_alt_name
t.integer :account_id, :index => true, :limit => 8, :null => false, :default => 1
t.string :status, :index => true
t.string :remark, :index => true
t.decimal :qty, :index => true, :precision => 10, :scale => 2, :null => false, :default => 0.00
t.decimal :unit_price, :index => true, :precision => 10, :scale => 2, :null => false, :default => 0.00
t.decimal :taxable_price, :index => true, :precision => 10, :scale => 2, :null => false, :default => 0.00
t.decimal :price, :index => true, :precision => 10, :scale => 2, :null => false, :default => 0.00
t.boolean :is_taxable, :index => true, :null => false, :default => true
t.timestamps
end
add_index :sale_items, [:sale_id, :account_id, :status, :remark, :qty, :unit_price, :taxable_price, :price, :is_taxable], name: 'index_sale_items'
end
end