[
  {
    "type": "create_table",
    "description": "Spec 050 Kiosk API v1: tablet pairing codes. An admin generates a short, single-use, time-limited code bound to their store; a new tablet enters the code (no typeNum/apiKey baked in) and the server matches it to the store and issues the device JWT pair. Lives in kiosk_buykiosk alongside kioskDevices.",
    "database": "kiosk_buykiosk",
    "check_query": "SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'kiosk_buykiosk' AND TABLE_NAME = 'kioskPairingCodes'",
    "sql": "CREATE TABLE `kioskPairingCodes` (\n  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,\n  `code` VARCHAR(16) NOT NULL COMMENT 'Normalized (uppercase, no separators) pairing code',\n  `typeNum` VARCHAR(10) NOT NULL COMMENT 'Store the code provisions',\n  `createdByUserId` INT UNSIGNED DEFAULT NULL COMMENT 'users.id of the admin who generated it',\n  `deviceName` VARCHAR(255) DEFAULT NULL COMMENT 'Optional friendly name pre-assigned to the device',\n  `expiresAt` DATETIME NOT NULL COMMENT 'Code expiration (short TTL)',\n  `usedAt` DATETIME DEFAULT NULL COMMENT 'When redeemed; NULL = still redeemable (single-use)',\n  `deviceId` INT UNSIGNED DEFAULT NULL COMMENT 'kioskDevices.id that redeemed the code (audit)',\n  `createdAt` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n  PRIMARY KEY (`id`),\n  UNIQUE KEY `uk_code` (`code`),\n  KEY `idx_typeNum` (`typeNum`),\n  KEY `idx_expiresAt` (`expiresAt`),\n  KEY `idx_typeNum_active` (`typeNum`, `usedAt`, `expiresAt`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Spec 050: single-use tablet pairing codes for Kiosk API v1'"
  }
]
