class AddRemoveIndexs < ActiveRecord::Migration[5.1]
  def change
    # remove_index "menu_items", name: "index_item_code"
    add_index :menu_items, [:shop_code, :item_code]

    # remove_index "orders", name: "index_source"
    # remove_index "orders", name: "index_date"
    # remove_index "orders", name: "index_status"
    add_index :orders, [:shop_code, :status]
    add_index :orders, [:shop_code, :source]
    add_index :orders, [:shop_code, :date]
    add_index :orders, [:shop_code, :source, :status, :date], name: "index_orders_on_source_status"

    # remove_index "order_items", name: "index_order_id"

    # remove_index "dining_facilities", name: "index_status"
    # remove_index "dining_facilities", name: "index_type"
    # remove_index "dining_facilities", name: "index_is_active"
    # remove_index "dining_facilities", name: "index_status_type_is_active"
    add_index :dining_facilities, [:shop_code, :is_active]
    add_index :dining_facilities, [:shop_code, :status]
    add_index :dining_facilities, [:shop_code, :type]
    add_index :dining_facilities, [:shop_code, :is_active, :status], name: 'index_dining_facilities_on_active_status'

    # remove_index "sale_items", name: "index_sale_items"
    # remove_index "sale_items", name: "index_sale_id"
    # remove_index "sale_items", name: "index_account_id"
    # remove_index "sale_items", name: "index_status"
    # remove_index "sale_items", name: "index_remark"
    # remove_index "sale_items", name: "index_qty"
    # remove_index "sale_items", name: "index_unit_ptice"
    # remove_index "sale_items", name: "index_taxable_price"
    # remove_index "sale_items", name: "index_ptice"
    # remove_index "sale_items", name: "index_is_taxable"
    add_index :sale_items, [:shop_code, :status]

    # remove_index "sale_taxes", name: "index_sale_id"

    # remove_index "sale_payments", name: "index_sale_id"
    # remove_index "sale_payments", name: "index_payment_method"
    # remove_index "sale_payments", name: "index_sale_id_payment_method"
    add_index :sale_payments, [:shop_code, :payment_method]

    # remove_index "sale_orders", name: "index_sale_id"
    # remove_index "sale_orders",  name: "index_order_id"

    # remove_index "sale_audits", name: "index_sale_audits"

    # remove_index "lookups", name: "index_lookup_type"
    add_index :lookups, [:shop_code, :lookup_type]

    # remove_index "bookings", name: "index_bookings"
    # remove_index "bookings", name: "index_checkin_at"
    # remove_index "bookings", name: "index_checkout_by"
    # remove_index "bookings", name: "index_reserved_by"
    # remove_index "bookings", name: "index_booking_status"
    add_index :bookings, [:shop_code, :booking_status]

    # remove_index "seed_generators", name: "index_seed_model"
    add_index :seed_generators, [:shop_code, :model]

    # remove_index "assigned_order_items", name: "index_assigned_order_items"
    # remove_index "assigned_order_items", name: "index_item_code"
    # remove_index "assigned_order_items", name: "index_instance_code"
    # remove_index "assigned_order_items", name: "index_order_queue_station_id"
    # remove_index "assigned_order_items", name: "index_delivery_status"
    # remove_index "assigned_order_items", name: "index_created_at"
    add_index :assigned_order_items, [:shop_code, :item_code]
    add_index :assigned_order_items, [:shop_code, :instance_code]
    add_index :assigned_order_items, [:shop_code, :item_code, :instance_code], name: 'index_assigned_items_on_codes'

    # remove_index "booking_orders", name: "index_booking_id"
    # remove_index "booking_orders", name: "index_order_id"

    # remove_index "customers", name: "index_membership_id"
    # remove_index "customers", name: "index_customer_type"
    add_index :customers, [:shop_code, :customer_type]

    # remove_index "shift_sales", name: "index_shift_started_at"
    # remove_index "shift_sales", name: "index_shift_closed_at"
    # remove_index "shift_sales", name: "index_shift_started_at_closed_at"
    add_index :shift_sales, [:shop_code, :shift_started_at, :shift_closed_at], name: 'index_shifts_on_time'

    # remove_index "print_settings", name: "index_unique_code"
    add_index :print_settings, [:shop_code, :unique_code]

    # remove_index "sales", name: "index_sales"
    # remove_index "sales", name: "index_receipt_date"
    # remove_index "sales", name: "index_payment_status"
    # remove_index "sales", name: "index_sale_status"
    # remove_index "sales", name: "index_sale_shift_sale_id"
    add_index :sales, [:shop_code, :sale_status]
    add_index :sales, [:shop_code, :payment_status]
    add_index :sales, [:shop_code, :sale_status, :payment_status]

    # remove_index "promotions", name: "index_promotions"
    # remove_index "promotions", name: "index_promo_start_date"
    # remove_index "promotions", name: "index_promo_end_date"
    # remove_index "promotions", name: "index_promo_start_hour"
    # remove_index "promotions", name: "index_promo_end_hour"
    add_index :promotions, [:shop_code, :promo_start_date, :promo_end_date, :promo_start_hour, :promo_end_hour], name: 'index_promotions_on_time'
  end
end
