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 t.string :product_code, :null => false t.string :item_instance_code t.string :product_name, :null => false t.string :product_alt_name, :null => false t.integer :account_id, :limit => 8, :null => false, :default => 1 t.string :remark t.decimal :qty, :precision => 10, :scale => 2, :null => false, :default => 0.00 t.decimal :unit_price, :precision => 10, :scale => 2, :null => false, :default => 0.00 t.decimal :taxable_price, :precision => 10, :scale => 2, :null => false, :default => 0.00 t.decimal :price, :precision => 10, :scale => 2, :null => false, :default => 0.00 t.boolean :is_taxable, :null => false, :default => true t.timestamps end end end