Skip to content

Commit

Permalink
Merge pull request #489 from KarlLevik/modeling-63
Browse files Browse the repository at this point in the history
New tables DewarRegistry and DewarRegistry_has_Proposal
  • Loading branch information
delageniere authored Oct 20, 2020
2 parents 235dec4 + ba56a7c commit 030386b
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions ispyb-ejb/db/scripts/ahead/2020_09_09_DewarRegistry_tables.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
INSERT IGNORE INTO SchemaStatus (scriptName, schemaStatus) VALUES ('2020_09_09_DewarRegistry_tables.sql', 'ONGOING');

CREATE TABLE `DewarRegistry` (
`dewarRegistryId` int(11) unsigned NOT NULL AUTO_INCREMENT,
`facilityCode` varchar(20) NOT NULL,
`proposalId` int(11) unsigned DEFAULT NULL,
`labContactId` int(11) unsigned DEFAULT NULL,
`purchaseDate` datetime DEFAULT NULL,
`bltimestamp` datetime NOT NULL DEFAULT current_timestamp(),
PRIMARY KEY (`dewarRegistryId`),
UNIQUE KEY `facilityCode` (`facilityCode`),
KEY `DewarRegistry_ibfk_1` (`proposalId`),
KEY `DewarRegistry_ibfk_2` (`labContactId`),
CONSTRAINT `DewarRegistry_ibfk_1` FOREIGN KEY (`proposalId`) REFERENCES `Proposal` (`proposalId`) ON DELETE NO ACTION ON UPDATE CASCADE,
CONSTRAINT `DewarRegistry_ibfk_2` FOREIGN KEY (`labContactId`) REFERENCES `LabContact` (`labContactId`) ON DELETE SET NULL ON UPDATE CASCADE
);

CREATE TABLE `DewarRegistry_has_Proposal` (
`dewarRegistryHasProposalId` int(11) unsigned NOT NULL AUTO_INCREMENT,
`dewarRegistryId` int(11) unsigned DEFAULT NULL,
`proposalId` int(10) unsigned DEFAULT NULL,
`personId` int(10) unsigned DEFAULT NULL COMMENT 'Person registering the dewar',
`recordTimestamp` datetime DEFAULT current_timestamp(),
`labContactId` int(11) unsigned DEFAULT NULL COMMENT 'Owner of the dewar',
PRIMARY KEY (`dewarRegistryHasProposalId`),
UNIQUE KEY `dewarRegistryId` (`dewarRegistryId`,`proposalId`),
KEY `DewarRegistry_has_Proposal_ibfk2` (`proposalId`),
KEY `DewarRegistry_has_Proposal_ibfk3` (`personId`),
KEY `DewarRegistry_has_Proposal_ibfk4` (`labContactId`),
CONSTRAINT `DewarRegistry_has_Proposal_ibfk1` FOREIGN KEY (`dewarRegistryId`) REFERENCES `DewarRegistry` (`dewarRegistryId`),
CONSTRAINT `DewarRegistry_has_Proposal_ibfk2` FOREIGN KEY (`proposalId`) REFERENCES `Proposal` (`proposalId`),
CONSTRAINT `DewarRegistry_has_Proposal_ibfk3` FOREIGN KEY (`personId`) REFERENCES `Person` (`personId`),
CONSTRAINT `DewarRegistry_has_Proposal_ibfk4` FOREIGN KEY (`labContactId`) REFERENCES `LabContact` (`labContactId`) ON DELETE NO ACTION ON UPDATE CASCADE
);

UPDATE SchemaStatus SET schemaStatus = 'DONE' WHERE scriptName = '2020_09_09_DewarRegistry_tables.sql';

0 comments on commit 030386b

Please sign in to comment.