USE zylon_db;

ALTER TABLE orders
  ADD COLUMN payment_authority VARCHAR(100) DEFAULT NULL AFTER payment_ref,
  ADD COLUMN gateway VARCHAR(40) DEFAULT 'zarinpal' AFTER payment_authority,
  ADD COLUMN tracking_code VARCHAR(60) DEFAULT NULL AFTER gateway,
  ADD COLUMN shipping_amount DECIMAL(12,2) NOT NULL DEFAULT 0 AFTER tracking_code,
  ADD COLUMN discount_amount DECIMAL(12,2) NOT NULL DEFAULT 0 AFTER shipping_amount;

CREATE INDEX idx_orders_status ON orders (status);
CREATE INDEX idx_orders_payment_status ON orders (payment_status);
CREATE INDEX idx_orders_authority ON orders (payment_authority);

CREATE INDEX idx_products_title ON products (title);
CREATE INDEX idx_products_sku ON products (sku);
CREATE INDEX idx_products_category ON products (category);
CREATE INDEX idx_order_items_order_id ON order_items (order_id);
