From b1cc72e83ed7de87c4af61dd6d7d58e1faec669d Mon Sep 17 00:00:00 2001 From: Stuart Fisher Date: Tue, 28 Jun 2022 15:06:54 +0200 Subject: [PATCH 1/6] detector roi wip --- .../updates/2022_06_28_detector_rois.sql | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 schemas/ispyb/updates/2022_06_28_detector_rois.sql diff --git a/schemas/ispyb/updates/2022_06_28_detector_rois.sql b/schemas/ispyb/updates/2022_06_28_detector_rois.sql new file mode 100644 index 00000000..d6fb9b49 --- /dev/null +++ b/schemas/ispyb/updates/2022_06_28_detector_rois.sql @@ -0,0 +1,30 @@ +INSERT IGNORE INTO SchemaStatus (scriptName, schemaStatus) VALUES ('2022_06_28_detector_rois.sql', 'ONGOING'); + +DROP TABLE IF EXISTS `DetectorROI`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `DetectorROI` ( + `detectorROIId` int(11) unsigned NOT NULL AUTO_INCREMENT, + `detectorId` int(11) NOT NULL, + `blSampleId` int(10) unsigned NOT NULL, + `type` varchar(50) DEFAULT NULL COMMENT 'The ROI type rectangle, arc, q range, etc', + `name` varchar(50) DEFAULT NULL COMMENT 'A short name for this ROI', + `blTimestamp` timestamp NOT NULL DEFAULT current_timestamp(), + `definition` text DEFAULT NULL COMMENT 'The ROI definition in json format', + PRIMARY KEY (`detectorROIId`), + KEY `detectorROI_fk1` (`detectorId`), + KEY `detectorROI_fk2` (`blSampleId`), + CONSTRAINT `detectorROI_fk1` FOREIGN KEY (`detectorId`) REFERENCES `Detector` (`detectorId`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `detectorROI_fk2` FOREIGN KEY (`blSampleId`) REFERENCES `BLSample` (`blSampleId`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +ALTER TABLE `XRFFluorescenceMapping` + CHANGE `xrfFluorescenceMappingROIId` `xrfFluorescenceMappingROIId` int(11) unsigned NULL, + ADD `detectorROIId` int(11) unsigned NULL, + ADD CONSTRAINT `XRFFluorescenceMapping_ibfk4` + FOREIGN KEY (`detectorROIId`) + REFERENCES `DetectorROI`(`detectorROIId`) + ON DELETE NO ACTION ON UPDATE NO ACTION + +UPDATE SchemaStatus SET schemaStatus = 'DONE' WHERE scriptName = '2022_06_28_detector_rois.sql'; From b49ffcd558a651b982f81c304fc01626eae78a20 Mon Sep 17 00:00:00 2001 From: Stuart Fisher Date: Tue, 16 Aug 2022 13:14:23 +0200 Subject: [PATCH 2/6] add comment, correct charset, update not nulls, fix syntax --- schemas/ispyb/updates/2022_06_28_detector_rois.sql | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/schemas/ispyb/updates/2022_06_28_detector_rois.sql b/schemas/ispyb/updates/2022_06_28_detector_rois.sql index d6fb9b49..d8d2758d 100644 --- a/schemas/ispyb/updates/2022_06_28_detector_rois.sql +++ b/schemas/ispyb/updates/2022_06_28_detector_rois.sql @@ -7,16 +7,16 @@ CREATE TABLE `DetectorROI` ( `detectorROIId` int(11) unsigned NOT NULL AUTO_INCREMENT, `detectorId` int(11) NOT NULL, `blSampleId` int(10) unsigned NOT NULL, - `type` varchar(50) DEFAULT NULL COMMENT 'The ROI type rectangle, arc, q range, etc', - `name` varchar(50) DEFAULT NULL COMMENT 'A short name for this ROI', + `type` varchar(50) NOT NULL COMMENT 'The ROI type rectangle, arc, q range, etc', + `name` varchar(50) NOT NULL COMMENT 'A short name for this ROI', `blTimestamp` timestamp NOT NULL DEFAULT current_timestamp(), - `definition` text DEFAULT NULL COMMENT 'The ROI definition in json format', + `definition` text NOT NULL CHECK (json_valid(`scanParameters`)) COMMENT 'The ROI definition in json format', PRIMARY KEY (`detectorROIId`), KEY `detectorROI_fk1` (`detectorId`), KEY `detectorROI_fk2` (`blSampleId`), CONSTRAINT `detectorROI_fk1` FOREIGN KEY (`detectorId`) REFERENCES `Detector` (`detectorId`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `detectorROI_fk2` FOREIGN KEY (`blSampleId`) REFERENCES `BLSample` (`blSampleId`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Store an ROI for a 2d detector against a particular sample'; /*!40101 SET character_set_client = @saved_cs_client */; ALTER TABLE `XRFFluorescenceMapping` @@ -24,7 +24,6 @@ ALTER TABLE `XRFFluorescenceMapping` ADD `detectorROIId` int(11) unsigned NULL, ADD CONSTRAINT `XRFFluorescenceMapping_ibfk4` FOREIGN KEY (`detectorROIId`) - REFERENCES `DetectorROI`(`detectorROIId`) - ON DELETE NO ACTION ON UPDATE NO ACTION + REFERENCES `DetectorROI`(`detectorROIId`); UPDATE SchemaStatus SET schemaStatus = 'DONE' WHERE scriptName = '2022_06_28_detector_rois.sql'; From 5a8215ec00a6e3d29749558843c73357bc7999ba Mon Sep 17 00:00:00 2001 From: Stuart Fisher Date: Tue, 16 Aug 2022 13:15:18 +0200 Subject: [PATCH 3/6] typo --- schemas/ispyb/updates/2022_06_28_detector_rois.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schemas/ispyb/updates/2022_06_28_detector_rois.sql b/schemas/ispyb/updates/2022_06_28_detector_rois.sql index d8d2758d..1958eca4 100644 --- a/schemas/ispyb/updates/2022_06_28_detector_rois.sql +++ b/schemas/ispyb/updates/2022_06_28_detector_rois.sql @@ -10,7 +10,7 @@ CREATE TABLE `DetectorROI` ( `type` varchar(50) NOT NULL COMMENT 'The ROI type rectangle, arc, q range, etc', `name` varchar(50) NOT NULL COMMENT 'A short name for this ROI', `blTimestamp` timestamp NOT NULL DEFAULT current_timestamp(), - `definition` text NOT NULL CHECK (json_valid(`scanParameters`)) COMMENT 'The ROI definition in json format', + `definition` text NOT NULL CHECK (json_valid(`definition`)) COMMENT 'The ROI definition in json format', PRIMARY KEY (`detectorROIId`), KEY `detectorROI_fk1` (`detectorId`), KEY `detectorROI_fk2` (`blSampleId`), From 72c9135b09c4d904796872563a9cb1c96d7e9e87 Mon Sep 17 00:00:00 2001 From: Stuart Fisher Date: Wed, 17 Aug 2022 11:58:59 +0200 Subject: [PATCH 4/6] remove charset --- schemas/ispyb/updates/2022_06_28_detector_rois.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schemas/ispyb/updates/2022_06_28_detector_rois.sql b/schemas/ispyb/updates/2022_06_28_detector_rois.sql index 1958eca4..ee4f2af2 100644 --- a/schemas/ispyb/updates/2022_06_28_detector_rois.sql +++ b/schemas/ispyb/updates/2022_06_28_detector_rois.sql @@ -16,7 +16,7 @@ CREATE TABLE `DetectorROI` ( KEY `detectorROI_fk2` (`blSampleId`), CONSTRAINT `detectorROI_fk1` FOREIGN KEY (`detectorId`) REFERENCES `Detector` (`detectorId`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `detectorROI_fk2` FOREIGN KEY (`blSampleId`) REFERENCES `BLSample` (`blSampleId`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Store an ROI for a 2d detector against a particular sample'; +) ENGINE=InnoDB DEFAULT COMMENT='Store an ROI for a 2d detector against a particular sample'; /*!40101 SET character_set_client = @saved_cs_client */; ALTER TABLE `XRFFluorescenceMapping` From 6bec416632318eac4021411673f8dc88e03cff4c Mon Sep 17 00:00:00 2001 From: Stuart Fisher Date: Thu, 18 Aug 2022 12:18:07 +0200 Subject: [PATCH 5/6] comment / check ordering --- schemas/ispyb/updates/2022_06_28_detector_rois.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schemas/ispyb/updates/2022_06_28_detector_rois.sql b/schemas/ispyb/updates/2022_06_28_detector_rois.sql index ee4f2af2..1761e1b1 100644 --- a/schemas/ispyb/updates/2022_06_28_detector_rois.sql +++ b/schemas/ispyb/updates/2022_06_28_detector_rois.sql @@ -10,7 +10,7 @@ CREATE TABLE `DetectorROI` ( `type` varchar(50) NOT NULL COMMENT 'The ROI type rectangle, arc, q range, etc', `name` varchar(50) NOT NULL COMMENT 'A short name for this ROI', `blTimestamp` timestamp NOT NULL DEFAULT current_timestamp(), - `definition` text NOT NULL CHECK (json_valid(`definition`)) COMMENT 'The ROI definition in json format', + `definition` text NOT NULL COMMENT 'The ROI definition in json format' CHECK (json_valid(`definition`)), PRIMARY KEY (`detectorROIId`), KEY `detectorROI_fk1` (`detectorId`), KEY `detectorROI_fk2` (`blSampleId`), From b456117de1424c4909d64fc63ebf041220e670b2 Mon Sep 17 00:00:00 2001 From: Stuart Fisher Date: Thu, 18 Aug 2022 12:20:45 +0200 Subject: [PATCH 6/6] default --- schemas/ispyb/updates/2022_06_28_detector_rois.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schemas/ispyb/updates/2022_06_28_detector_rois.sql b/schemas/ispyb/updates/2022_06_28_detector_rois.sql index 1761e1b1..21acb098 100644 --- a/schemas/ispyb/updates/2022_06_28_detector_rois.sql +++ b/schemas/ispyb/updates/2022_06_28_detector_rois.sql @@ -16,7 +16,7 @@ CREATE TABLE `DetectorROI` ( KEY `detectorROI_fk2` (`blSampleId`), CONSTRAINT `detectorROI_fk1` FOREIGN KEY (`detectorId`) REFERENCES `Detector` (`detectorId`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `detectorROI_fk2` FOREIGN KEY (`blSampleId`) REFERENCES `BLSample` (`blSampleId`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT COMMENT='Store an ROI for a 2d detector against a particular sample'; +) ENGINE=InnoDB COMMENT='Store an ROI for a 2d detector against a particular sample'; /*!40101 SET character_set_client = @saved_cs_client */; ALTER TABLE `XRFFluorescenceMapping`