add index in migrate file
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
class CreateMenuItems < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
create_table :menu_items do |t|
|
||||
t.string :item_code, :null => false
|
||||
t.string :item_code, :null => false, :index => true
|
||||
t.string :name, :null => false
|
||||
t.string :alt_name
|
||||
t.string :image_path
|
||||
|
||||
@@ -2,17 +2,18 @@ class CreateOrders < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
create_table :orders, :id => false do |t|
|
||||
t.string :order_id, :limit => 16, :primary_key => true #custom foreign_key to prevent conflict during sync
|
||||
t.datetime :date, :null => false
|
||||
t.string :source, :null => false, :default => "emenu"
|
||||
t.datetime :date, :index => true, :null => false
|
||||
t.string :source, :index => true, :null => false, :default => "emenu"
|
||||
t.string :order_type, :null => false, :default => "dine-in"
|
||||
t.string :customer_id, foreign_key: true, :limit => 16
|
||||
t.integer :item_count, :null => false, :default => 0
|
||||
t.integer :quantity_count, :null => false, :default => 0
|
||||
t.string :status, :null => false, :default => "new"
|
||||
t.string :status, :index => true, :null => false, :default => "new"
|
||||
t.json :waiters
|
||||
t.json :guest_info
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
add_index :orders, [:date, :source, :status], name: 'index_date_source_status'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@ class CreateOrderItems < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
create_table :order_items, :id => false do |t|
|
||||
t.string :order_items_id, :limit => 16, :primary_key => true #custom primary key - to ensure consistence for cloud syncing
|
||||
t.string :order_id, foreign_key: true, :null => false, :limit => 16
|
||||
t.string :order_id, foreign_key: true, :index => true, :null => false, :limit => 16
|
||||
t.string :order_item_status, :null => false, :default => "new"
|
||||
t.string :item_order_by #person who order this
|
||||
t.string :item_code, :null => false
|
||||
|
||||
@@ -3,15 +3,16 @@ class CreateDiningFacilities < ActiveRecord::Migration[5.1]
|
||||
create_table :dining_facilities do |t|
|
||||
t.references :zone, foreign_key: true
|
||||
t.string :name, :null => false
|
||||
t.string :status, :null => false, :default => "available"
|
||||
t.string :type, :null => false, :default => "Table"
|
||||
t.string :status, :null => false, :default => "available", :index => true
|
||||
t.string :type, :null => false, :default => "Table", :index => true
|
||||
t.integer :seater, :null => false, :default => 2
|
||||
t.integer :order_by
|
||||
|
||||
t.string :created_by
|
||||
t.boolean :is_active, :null => false, :default => true
|
||||
t.boolean :is_active, :null => false, :default => true, :index => true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
add_index :dining_facilities, [:status, :type, :is_active]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,15 +3,16 @@ class CreateEmployees < ActiveRecord::Migration[5.1]
|
||||
create_table :employees do |t|
|
||||
t.string :name, :null => false
|
||||
t.string :role, :null => false, :default => "cashier"
|
||||
t.boolean :is_active, :default => true
|
||||
t.boolean :is_active, :default => true, :index=>true
|
||||
t.string :emp_id, :null => false
|
||||
t.string :password_digest, :null => false
|
||||
t.string :token_session
|
||||
t.string :token_session, :index=>true
|
||||
t.datetime :session_expiry
|
||||
t.datetime :session_last_login
|
||||
t.string :created_by
|
||||
t.string :image_path
|
||||
t.timestamps
|
||||
end
|
||||
add_index :employees, [:is_active, :token_session]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,21 +2,22 @@ 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 :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, :null => false
|
||||
t.integer :account_id, :limit => 8, :null => false, :default => 1
|
||||
t.string :status
|
||||
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.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
|
||||
|
||||
@@ -3,7 +3,7 @@ class CreateSaleTaxes < ActiveRecord::Migration[5.1]
|
||||
create_table :sale_taxes, :id => false do |t|
|
||||
t.string :sale_tax_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 :sale_id, foreign_key: true, :limit => 16, :index => true, :null => false
|
||||
t.string :tax_name, :null => false
|
||||
t.decimal :tax_rate, :precision => 10, :scale => 2, :null => false, :default => 0.00
|
||||
t.decimal :tax_payable_amount, :precision => 10, :scale => 2, :null => false, :default => 0.00
|
||||
|
||||
@@ -3,8 +3,8 @@ class CreateSalePayments < ActiveRecord::Migration[5.1]
|
||||
create_table :sale_payments, :id => false do |t|
|
||||
t.string :sale_payment_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 :payment_method, :null => false, :default => "cash"
|
||||
t.string :sale_id, foreign_key: true, :limit => 16, :index => true
|
||||
t.string :payment_method, :null => false, :default => "cash", :index => true
|
||||
t.decimal :payment_amount, :precision => 10, :scale => 2, :null => false, :default => 0.00
|
||||
t.decimal :outstanding_amount, :precision => 10, :scale => 2, :null => false, :default => 0.00
|
||||
t.string :payment_reference
|
||||
@@ -12,5 +12,6 @@ class CreateSalePayments < ActiveRecord::Migration[5.1]
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
add_index :sale_payments, [:sale_id, :payment_method]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,10 +3,11 @@ class CreateSaleOrders < ActiveRecord::Migration[5.1]
|
||||
create_table :sale_orders, :id => false do |t|
|
||||
|
||||
t.string :sale_order_id, :limit => 16, :primary_key => true
|
||||
t.string :sale_id, foreign_key: true,:limit => 16
|
||||
t.string :order_id, foreign_key: true, :limit => 16
|
||||
t.string :sale_id, foreign_key: true,:limit => 16, :index => true
|
||||
t.string :order_id, foreign_key: true, :limit => 16, :index => true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
add_index :sale_orders, [:sale_id, :order_id], name: 'index_sale_id_order_id'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class CreateLookups < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
create_table :lookups do |t|
|
||||
t.string :lookup_type, :null => false
|
||||
t.string :lookup_type, :null => false, :index => true
|
||||
t.string :name, :null => false
|
||||
t.string :value, :null => false
|
||||
end
|
||||
|
||||
@@ -5,17 +5,18 @@ class CreateBookings < ActiveRecord::Migration[5.1]
|
||||
|
||||
t.references :dining_facility, foreign_key: true
|
||||
t.string :type, :null => false, :default => "Table"
|
||||
t.datetime :checkin_at, :null => false
|
||||
t.datetime :checkin_at, :index => true, :null => false
|
||||
t.string :checkin_by
|
||||
t.datetime :checkout_at
|
||||
t.string :checkout_by
|
||||
t.string :checkout_by, :index => true
|
||||
t.datetime :reserved_at
|
||||
t.string :reserved_by
|
||||
t.string :booking_status, :null => false, :default => "new"
|
||||
t.string :reserved_by, :index => true
|
||||
t.string :booking_status, :index => true, :null => false, :default => "new"
|
||||
t.string :sale_id, foreign_key: true, :limit => 16
|
||||
t.string :customer_id, foreign_key: true, :limit => 16
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
add_index :bookings, [:checkin_at, :checkout_by, :reserved_by, :booking_status], name: 'index_bookings'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class CreateSeedGenerators < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
create_table :seed_generators do |t|
|
||||
t.string :model, :null => false, :default => "sale"
|
||||
t.string :model, :null => false, :default => "sale", :index => true
|
||||
t.integer :increase_by, :null => false, :default => 1
|
||||
t.bigint :current, :null => false ,:default => 1
|
||||
t.bigint :next, :null => false, :default => 2
|
||||
|
||||
@@ -4,12 +4,14 @@ class CreateAssignedOrderItems < ActiveRecord::Migration[5.1]
|
||||
t.string :assigned_order_item_id, :limit => 16, :primary_key => true #custom primary key - to ensure consistence for cloud syncing
|
||||
t.string :item_code, :null => false, :index => true
|
||||
t.string :instance_code, :null => false, :index => true
|
||||
t.references :order_queue_station, foreign_key: true
|
||||
t.references :order_queue_station, foreign_key: true, :index => true
|
||||
t.string :order_id, foreign_key: true, :limit => 16
|
||||
t.boolean :print_status
|
||||
t.boolean :delivery_status
|
||||
t.boolean :delivery_status, :index => true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
add_index :assigned_order_items, :created_at
|
||||
add_index :assigned_order_items, [:item_code, :instance_code, :order_queue_station_id, :delivery_status, :created_at], name: 'index_assigned_order_items'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,10 +3,11 @@ class CreateBookingOrders < ActiveRecord::Migration[5.1]
|
||||
create_table :booking_orders, :id => false do |t|
|
||||
#t.string :booking_order_id, :limit => 16, :null => false, :index => true, :unique => true #custom primary key - to ensure consistence for cloud syncing
|
||||
t.primary_key :booking_order_id
|
||||
t.string :booking_id, foreign_key: true, :limit => 16
|
||||
t.string :order_id, foreign_key: true, :limit => 16
|
||||
t.string :booking_id, foreign_key: true, :index => true, :limit => 16
|
||||
t.string :order_id, foreign_key: true, :index => true, :limit => 16
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
add_index :booking_orders, [:booking_id, :order_id], name: 'index_booking_id_order_id'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -13,12 +13,13 @@ class CreateCustomers < ActiveRecord::Migration[5.1]
|
||||
t.string :address
|
||||
t.string :card_no, :unique => true
|
||||
t.string :paypar_account_no, :unique => true
|
||||
t.string :membership_id
|
||||
t.string :membership_id, :index => true
|
||||
t.string :membership_type
|
||||
t.string :membership_authentication_code
|
||||
t.string :customer_type, :default => "Dinein"
|
||||
t.string :customer_type, :default => "Dinein", :index => true
|
||||
t.json :tax_profiles
|
||||
t.string :image_path
|
||||
end
|
||||
add_index :customers, [:membership_id, :customer_type]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,8 +2,8 @@ class CreateShiftSales < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
create_table :shift_sales do |t|
|
||||
t.references :cashier_terminal, foreign_key: true, :null => false
|
||||
t.datetime :shift_started_at
|
||||
t.datetime :shift_closed_at
|
||||
t.datetime :shift_started_at, :index => true
|
||||
t.datetime :shift_closed_at, :index => true
|
||||
t.references :employee, foreign_key: true #cashier
|
||||
t.decimal :opening_balance, :precision => 10, :scale => 2, :null => false, :default => 0.00
|
||||
t.decimal :closing_balance, :precision => 10, :scale => 2, :null => false, :default => 0.00
|
||||
@@ -26,5 +26,6 @@ class CreateShiftSales < ActiveRecord::Migration[5.1]
|
||||
t.decimal :total_void, :default => 0
|
||||
t.timestamps
|
||||
end
|
||||
add_index :shift_sales, [:shift_started_at, :shift_closed_at]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@ class CreatePrintSettings < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
create_table :print_settings do |t|
|
||||
t.string :name, :null => false
|
||||
t.string :unique_code, :null => false
|
||||
t.string :unique_code, :null => false, :index => true
|
||||
t.string :template
|
||||
t.string :font, :default => ""
|
||||
t.integer :header_font_size, :null => false, :default => 10
|
||||
|
||||
@@ -8,10 +8,10 @@ class CreateSales < ActiveRecord::Migration[5.1]
|
||||
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.datetime :receipt_date, :index => true, :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.string :payment_status, :index => true, :null => false, :default => "outstanding"
|
||||
t.string :sale_status, :index => true, :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
|
||||
@@ -21,11 +21,13 @@ class CreateSales < ActiveRecord::Migration[5.1]
|
||||
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.integer :shift_sale_id, :index => true
|
||||
t.decimal :old_grand_total
|
||||
t.string :rebate_status
|
||||
t.integer :equal_persons
|
||||
t.timestamps
|
||||
end
|
||||
add_index :sales, :created_at, name: 'index_created_at'
|
||||
add_index :sales, [:cashier_id, :receipt_date, :payment_status, :sale_status, :shift_sale_id, :created_at], name: 'index_sales'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,10 +3,10 @@ class CreatePromotion < ActiveRecord::Migration[5.1]
|
||||
create_table :promotions do |t|
|
||||
t.string :promo_code, :limit => 16
|
||||
|
||||
t.date :promo_start_date, :null => false
|
||||
t.date :promo_end_date, :null => false
|
||||
t.time :promo_start_hour, :null => false
|
||||
t.time :promo_end_hour, :null => false
|
||||
t.date :promo_start_date, :null => false, :index => true
|
||||
t.date :promo_end_date, :null => false, :index => true
|
||||
t.time :promo_start_hour, :null => false, :index => true
|
||||
t.time :promo_end_hour, :null => false, :index => true
|
||||
t.string :promo_day, :null => false, :default => "[0,1,2,3,4,5,6]"
|
||||
t.string :promo_type, :null => false, :default => "Quantity"
|
||||
t.string :original_product
|
||||
@@ -14,5 +14,6 @@ class CreatePromotion < ActiveRecord::Migration[5.1]
|
||||
t.string :created_by, :null => false
|
||||
t.timestamps
|
||||
end
|
||||
add_index :promotions, [:promo_start_date, :promo_end_date, :promo_start_hour, :promo_end_hour], name: 'index_promotions'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class CreateCardSaleTrans < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
create_table :card_sale_trans do |t|
|
||||
t.string :sale_id
|
||||
t.string :sale_id, :index=>true
|
||||
t.date :req_date
|
||||
t.time :req_time
|
||||
t.float :req_amt, :limit=>50
|
||||
|
||||
Reference in New Issue
Block a user