[
  {
    "type": "alter_table",
    "description": "Add checkoutStatus to buyQueue so we can distinguish paid-out checkouts from voided checkouts (POS no-buy where customer must return for unsold items). NULL until checkedOut=1; 'paid' = customer accepted offer and was paid out; 'voided' = no items accepted, still allow workbook resend-SMS.",
    "database": "{{store}}",
    "check_query": "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'buyQueue' AND COLUMN_NAME = 'checkoutStatus'",
    "sql": "ALTER TABLE `buyQueue` ADD COLUMN `checkoutStatus` ENUM('paid','voided') NULL DEFAULT NULL COMMENT 'Set when checkedOut=1: paid = customer accepted and paid out; voided = no-buy, customer must return for items. NULL while still active.' AFTER `checkedOut`"
  },
  {
    "type": "update",
    "description": "Backfill checkoutStatus='paid' for existing checked-out rows. Every prior checkout path meant paid; this preserves that semantics for historical data so the new workbook badge and resend-SMS gate work correctly on legacy rows. Idempotent: only touches rows where checkoutStatus is still NULL.",
    "database": "{{store}}",
    "sql": "UPDATE `buyQueue` SET `checkoutStatus` = 'paid' WHERE `checkedOut` = 1 AND `checkoutStatus` IS NULL"
  }
]
