-- Public ZTE submission tokens — one per order, used to let customers
-- submit their Customer ID + Enrollment Token without logging in.
CREATE TABLE IF NOT EXISTS zte_submission_tokens (
  id INT AUTO_INCREMENT PRIMARY KEY,
  token VARCHAR(64) NOT NULL UNIQUE,
  order_id INT NOT NULL,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  submitted_at TIMESTAMP NULL,
  submitted_ip VARCHAR(45) NULL,
  INDEX idx_zte_tokens_order (order_id),
  INDEX idx_zte_tokens_submitted (submitted_at),
  CONSTRAINT fk_zte_tokens_order FOREIGN KEY (order_id) REFERENCES orders(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
