CREATE TABLE IF NOT EXISTS `inspection_objects` ( `id` INT AUTO_INCREMENT PRIMARY KEY, `modelId` INT NOT NULL, `name` VARCHAR(100) NOT NULL, `description` TEXT NULL, `status` ENUM('draft','active') NOT NULL DEFAULT 'draft', `defaultModelPointcloudId` INT NULL, `defaultModelCadFileId` INT NULL, `createdAt` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, `updatedAt` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, UNIQUE KEY `uk_inspection_objects_model_name` (`modelId`,`name`), KEY `idx_inspection_objects_model` (`modelId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; ALTER TABLE `model_pointcloud_files` ADD COLUMN `inspectionObjectId` INT NULL AFTER `filePath`, ADD COLUMN `status` ENUM('available','disabled') NOT NULL DEFAULT 'available' AFTER `inspectionObjectId`, ADD KEY `idx_model_pointcloud_object` (`inspectionObjectId`); ALTER TABLE `model_cad_files` ADD COLUMN `contentScope` ENUM('whole_vehicle') NOT NULL DEFAULT 'whole_vehicle' AFTER `filePath`, ADD COLUMN `status` ENUM('available','disabled') NOT NULL DEFAULT 'available' AFTER `contentScope`; CREATE TABLE IF NOT EXISTS `model_cad_inspection_objects` ( `cadFileId` INT NOT NULL, `inspectionObjectId` INT NOT NULL, UNIQUE KEY `uk_model_cad_inspection_object` (`cadFileId`,`inspectionObjectId`), KEY `idx_model_cad_object` (`inspectionObjectId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; ALTER TABLE `inspection_tasks` ADD COLUMN `inspectionObjectId` INT NULL AFTER `modelId`, ADD KEY `idx_inspection_tasks_object` (`inspectionObjectId`);