-- 旧监测列保留给既有数据;新版业务从独立接收状态开始演进。 ALTER TABLE t_test ADD COLUMN reception_status VARCHAR(32) NOT NULL DEFAULT 'NOT_STARTED' COMMENT '数据接收状态' AFTER monitoring_status, ADD CONSTRAINT chk_reception_status CHECK (reception_status IN ('NOT_STARTED', 'RECEIVING', 'PAUSED', 'ENDED')); CREATE TABLE t_test_collector_channel ( mapping_id BIGINT NOT NULL AUTO_INCREMENT, test_id BIGINT NOT NULL, battery_relation_id BIGINT NOT NULL, collector_id BIGINT NOT NULL, measurement_code VARCHAR(100) NOT NULL, measurement_name VARCHAR(100) NOT NULL, channel_code VARCHAR(32) NOT NULL, PRIMARY KEY (mapping_id), UNIQUE KEY uk_test_collector_measurement (battery_relation_id, measurement_code), UNIQUE KEY uk_test_collector_channel (test_id, collector_id, channel_code), KEY idx_test_collector_mapping (test_id, battery_relation_id), CONSTRAINT fk_test_collector_mapping_test FOREIGN KEY (test_id) REFERENCES t_test (test_id), CONSTRAINT fk_test_collector_mapping_battery FOREIGN KEY (battery_relation_id) REFERENCES t_test_battery (relation_id), CONSTRAINT fk_test_collector_mapping_collector FOREIGN KEY (collector_id) REFERENCES t_collector (collector_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='测试采集器通道映射'; CREATE TABLE t_test_field_snapshot ( snapshot_id BIGINT NOT NULL AUTO_INCREMENT, test_id BIGINT NOT NULL, field_definition_id BIGINT NOT NULL, field_name VARCHAR(100) NOT NULL, field_type VARCHAR(20) NOT NULL, field_value VARCHAR(500) NULL, PRIMARY KEY (snapshot_id), UNIQUE KEY uk_test_field_snapshot (test_id, field_definition_id), KEY idx_test_field_snapshot_test (test_id), CONSTRAINT fk_test_field_snapshot_test FOREIGN KEY (test_id) REFERENCES t_test (test_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='测试共享业务字段快照';