CREATE TABLE `raw_attendance_logs` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `tenant_id` bigint(20) unsigned NOT NULL, `device_id` bigint(20) unsigned NOT NULL, `personnel_code` varchar(50) NOT NULL, `punch_time` timestamp NOT NULL DEFAULT current_timestamp(), `punch_type` enum('in','out') NOT NULL DEFAULT 'in', `raw_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`raw_data`)), `is_processed` tinyint(1) NOT NULL DEFAULT 0, `processed_at` timestamp NULL DEFAULT NULL, `verify_mode` varchar(50) DEFAULT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `uq_device_personnel_time` (`device_id`,`personnel_code`,`punch_time`), KEY `raw_attendance_logs_tenant_id_is_processed_index` (`tenant_id`,`is_processed`), KEY `raw_attendance_logs_tenant_id_personnel_code_index` (`tenant_id`,`personnel_code`), KEY `raw_attendance_logs_tenant_id_punch_time_index` (`tenant_id`,`punch_time`), KEY `raw_attendance_logs_device_id_punch_time_index` (`device_id`,`punch_time`), KEY `idx_unprocessed_punch` (`is_processed`,`punch_time`), CONSTRAINT `raw_attendance_logs_device_id_foreign` FOREIGN KEY (`device_id`) REFERENCES `devices` (`id`) ON DELETE CASCADE, CONSTRAINT `raw_attendance_logs_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=356033 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci == index stats == total=297106 distinct identity=297106 dupes=0