-- =====================================================================
-- Section 6: public (no-login) ticket view via QR + GST frozen on each ticket.
-- Run once in phpMyAdmin against wbcorp_webapp.
-- =====================================================================

-- public_token: a random 32-character code that is the ONLY thing the QR link contains.
-- Ticket numbers / job ids are sequential and guessable, so they must never be usable as a public link.
-- Tokens are created automatically the first time a ticket is shown; older tickets get one then.
-- gst_percent: the GST % in force when the ticket was completed, so a later change to the GST setting
-- never alters an old ticket on reprint (NULL on old tickets = use the current setting, as before).
ALTER TABLE tblTransaction_Job
  ADD COLUMN public_token CHAR(32) NULL AFTER first_printed_at,
  ADD COLUMN gst_percent DECIMAL(5,2) NULL AFTER public_token,
  ADD UNIQUE KEY uq_job_public_token (public_token);
