[
  {
    "type": "create_table",
    "description": "Create userSessions table for active session tracking",
    "database": "kiosk_users",
    "check_query": "SHOW TABLES LIKE 'userSessions'",
    "sql": "CREATE TABLE `userSessions` (\n  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n  `userId` int(10) unsigned NOT NULL COMMENT 'FK to users.id',\n  `sessionId` varchar(255) NOT NULL COMMENT 'PHP session ID or unique identifier',\n  `ipAddress` varchar(45) DEFAULT NULL,\n  `userAgent` text DEFAULT NULL,\n  `deviceType` varchar(50) DEFAULT NULL COMMENT 'desktop, mobile, tablet',\n  `location` varchar(255) DEFAULT NULL COMMENT 'Geo location if available',\n  `createdAt` timestamp NOT NULL DEFAULT current_timestamp(),\n  `lastActivityAt` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),\n  `expiresAt` timestamp NOT NULL,\n  PRIMARY KEY (`id`),\n  UNIQUE KEY `uk_sessionId` (`sessionId`),\n  KEY `idx_userId` (`userId`),\n  KEY `idx_expiresAt` (`expiresAt`),\n  CONSTRAINT `fk_userSessions_user` FOREIGN KEY (`userId`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Active user sessions tracking'"
  }
]
