[
  {
    "type": "create_table",
    "description": "Create systemAlerts table for platform-wide admin broadcast messages",
    "database": "kiosk_buykiosk",
    "check_query": "SELECT 1 FROM information_schema.tables WHERE table_schema = 'kiosk_buykiosk' AND table_name = 'systemAlerts'",
    "sql": "CREATE TABLE IF NOT EXISTS `systemAlerts` (`id` int unsigned NOT NULL AUTO_INCREMENT, `title` varchar(255) NOT NULL, `body` text NOT NULL, `severity` enum('info','warning','critical') NOT NULL DEFAULT 'info', `displayType` enum('banner','toast') NOT NULL DEFAULT 'banner', `targetType` enum('all','specific') NOT NULL DEFAULT 'all', `ctaLabel` varchar(100) DEFAULT NULL, `ctaUrl` varchar(500) DEFAULT NULL, `expiresAt` datetime DEFAULT NULL, `isActive` tinyint(1) NOT NULL DEFAULT 1, `createdBy` int unsigned NOT NULL, `updatedBy` int unsigned DEFAULT NULL, `createdAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `updatedAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `idx_active_expires` (`isActive`, `expiresAt`), KEY `idx_created` (`createdAt`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;"
  },
  {
    "type": "create_table",
    "description": "Create systemAlertStoreTargets table for store-specific alert targeting",
    "database": "kiosk_buykiosk",
    "check_query": "SELECT 1 FROM information_schema.tables WHERE table_schema = 'kiosk_buykiosk' AND table_name = 'systemAlertStoreTargets'",
    "sql": "CREATE TABLE IF NOT EXISTS `systemAlertStoreTargets` (`id` int unsigned NOT NULL AUTO_INCREMENT, `alertId` int unsigned NOT NULL, `typeNum` varchar(10) NOT NULL, PRIMARY KEY (`id`), KEY `idx_alert` (`alertId`), KEY `idx_typenum` (`typeNum`), UNIQUE KEY `uq_alert_store` (`alertId`, `typeNum`), CONSTRAINT `fk_sast_alert` FOREIGN KEY (`alertId`) REFERENCES `systemAlerts` (`id`) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;"
  },
  {
    "type": "create_table",
    "description": "Create systemAlertAcknowledgments table for tracking per-user alert dismissals",
    "database": "kiosk_buykiosk",
    "check_query": "SELECT 1 FROM information_schema.tables WHERE table_schema = 'kiosk_buykiosk' AND table_name = 'systemAlertAcknowledgments'",
    "sql": "CREATE TABLE IF NOT EXISTS `systemAlertAcknowledgments` (`id` int unsigned NOT NULL AUTO_INCREMENT, `alertId` int unsigned NOT NULL, `userId` int unsigned NOT NULL, `dismissedAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `uq_alert_user` (`alertId`, `userId`), CONSTRAINT `fk_saa_alert` FOREIGN KEY (`alertId`) REFERENCES `systemAlerts` (`id`) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;"
  }
]
