Files
qiming/qiming-backend/sql/update-20260605.sql

25 lines
1.4 KiB
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
CREATE TABLE `digital_employee_sync_record`
(
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键',
`_tenant_id` BIGINT DEFAULT NULL COMMENT '租户ID',
`user_id` BIGINT DEFAULT NULL COMMENT '用户ID',
`client_key` VARCHAR(128) NOT NULL COMMENT '客户端配置Key',
`device_id` VARCHAR(128) DEFAULT NULL COMMENT '设备ID',
`outbox_id` VARCHAR(255) NOT NULL COMMENT '客户端outbox ID',
`entity_type` VARCHAR(32) NOT NULL COMMENT '实体类型plan/task/run/event/artifact/approval',
`entity_id` VARCHAR(255) NOT NULL COMMENT '客户端实体ID',
`operation` VARCHAR(32) NOT NULL COMMENT '操作类型',
`payload` JSON DEFAULT NULL COMMENT '实体快照',
`synced_at` DATETIME NOT NULL COMMENT '最近同步时间',
`modified` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`created` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `uk_client_outbox` (`client_key`, `outbox_id`),
KEY `idx_client_entity` (`client_key`, `entity_type`, `entity_id`),
KEY `idx_tenant_client_entity_time` (`_tenant_id`, `client_key`, `entity_type`, `entity_id`, `synced_at`),
KEY `idx_tenant_user_time` (`_tenant_id`, `user_id`, `synced_at`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_unicode_ci
COMMENT = '数字员工客户端同步记录';