-- Mobile upload visibility + protected tenant file access support
-- Run manually on MySQL if your schema already exists.

ALTER TABLE delivery_proofs
  MODIFY COLUMN proof_type ENUM('POD_PHOTO','DELIVERY_PHOTO','FAILED_PHOTO','CANCEL_PROOF','RETURN_PHOTO','SIGNATURE') NOT NULL;

CREATE INDEX idx_delivery_proofs_tenant_order_visible
  ON delivery_proofs (tenant_id, order_id, proof_type, is_delete, created_at);

CREATE INDEX idx_packing_photos_tenant_order_visible
  ON packing_photos (tenant_id, order_id, photo_type, is_delete, created_at);

CREATE INDEX idx_receiving_attachments_tenant_refs_visible
  ON receiving_attachments (tenant_id, receiving_scan_id, inbound_receipt_id, inbound_parcel_id, is_delete, created_at);
