class CreateSales < ActiveRecord::Migration[5.1] def change create_table :sales, :id => false do |t| t.string :sale_id, :limit => 16, :primary_key => true #custom primary key - to ensure consistence for cloud syncing t.integer :cashier_id, :index => true t.string :cashier_name t.string :requested_by, :null => false t.datetime :requested_at, :null => false t.string :receipt_no, :null => false t.datetime :receipt_date, :null => false t.string :customer_id, foreign_key: true, :limit => 16 t.string :payment_status, :null => false, :default => "outstanding" t.string :sale_status, :null => false, :default => "new" t.decimal :total_amount, :precision => 10, :scale => 2, :null => false, :default => 0.00 t.string :discount_type, :default => "overall" t.decimal :total_discount, :precision => 10, :scale => 2, :null => false, :default => 0.00 t.decimal :total_tax, :precision => 10, :scale => 2, :null => false, :default => 0.00 t.string :tax_type, :null => false , :dfault => "exclusive_tax" t.decimal :grand_total, :precision => 10, :scale => 2, :null => false, :default => 0.00 t.decimal :rounding_adjustment, :precision => 10, :scale => 2, :null => false, :default => 0.00 t.decimal :amount_received, :precision => 10, :scale => 2, :null => false, :default => 0.00 t.decimal :amount_changed, :precision => 10, :scale => 2, :null => false, :default => 0.00 t.integer :shift_sale_id t.decimal :old_grand_total t.string :rebate_status t.integer :equal_persons t.timestamps end end end