--liquibase formatted sql

--changeset fpsms:client_presence
--preconditions onFail:MARK_RAN
--precondition-sql-check expectedResult:0 SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'client_presence'
--comment: Live browser presence for tablet/desktop monitoring (heartbeat per device)
CREATE TABLE `client_presence` (
  `device_id` varchar(64) NOT NULL,
  `user_id` bigint DEFAULT NULL,
  `username` varchar(100) DEFAULT NULL,
  `display_name` varchar(128) DEFAULT NULL,
  `current_path` varchar(512) DEFAULT NULL,
  `client_type` varchar(16) NOT NULL DEFAULT 'unknown',
  `user_agent` varchar(512) DEFAULT NULL,
  `rtt_ms` int DEFAULT NULL,
  `connection_quality` varchar(16) NOT NULL DEFAULT 'good',
  `navigator_online` tinyint(1) NOT NULL DEFAULT 1,
  `last_heartbeat` datetime NOT NULL,
  `last_activity` datetime NOT NULL,
  `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`device_id`),
  KEY `idx_client_presence_last_heartbeat` (`last_heartbeat`),
  KEY `idx_client_presence_username` (`username`),
  KEY `idx_client_presence_client_type` (`client_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
