-- Runtime snapshots from Android: registration tier, tab list, policy summary (JSON).
-- Used by device_runtime_snapshot.php and post-upload verification.

CREATE TABLE IF NOT EXISTS `ftt_device_runtime_snapshots` (
  `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `device_id` VARCHAR(128) NOT NULL DEFAULT '',
  `correlation_id` VARCHAR(64) NOT NULL DEFAULT '',
  `package_name` VARCHAR(256) NOT NULL DEFAULT '',
  `version_code` INT NOT NULL DEFAULT 0,
  `version_name` VARCHAR(64) NOT NULL DEFAULT '',
  `tab_ids_hash` CHAR(64) NOT NULL DEFAULT '',
  `tab_count` INT NOT NULL DEFAULT 0,
  `payload_json` LONGTEXT NOT NULL,
  `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `idx_device_created` (`device_id`, `created_at`),
  KEY `idx_version` (`version_code`),
  KEY `idx_correlation` (`correlation_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
