Skip to content

Commit 030386b

Browse files
authored
Merge pull request #489 from KarlLevik/modeling-63
New tables DewarRegistry and DewarRegistry_has_Proposal
2 parents 235dec4 + ba56a7c commit 030386b

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
INSERT IGNORE INTO SchemaStatus (scriptName, schemaStatus) VALUES ('2020_09_09_DewarRegistry_tables.sql', 'ONGOING');
2+
3+
CREATE TABLE `DewarRegistry` (
4+
`dewarRegistryId` int(11) unsigned NOT NULL AUTO_INCREMENT,
5+
`facilityCode` varchar(20) NOT NULL,
6+
`proposalId` int(11) unsigned DEFAULT NULL,
7+
`labContactId` int(11) unsigned DEFAULT NULL,
8+
`purchaseDate` datetime DEFAULT NULL,
9+
`bltimestamp` datetime NOT NULL DEFAULT current_timestamp(),
10+
PRIMARY KEY (`dewarRegistryId`),
11+
UNIQUE KEY `facilityCode` (`facilityCode`),
12+
KEY `DewarRegistry_ibfk_1` (`proposalId`),
13+
KEY `DewarRegistry_ibfk_2` (`labContactId`),
14+
CONSTRAINT `DewarRegistry_ibfk_1` FOREIGN KEY (`proposalId`) REFERENCES `Proposal` (`proposalId`) ON DELETE NO ACTION ON UPDATE CASCADE,
15+
CONSTRAINT `DewarRegistry_ibfk_2` FOREIGN KEY (`labContactId`) REFERENCES `LabContact` (`labContactId`) ON DELETE SET NULL ON UPDATE CASCADE
16+
);
17+
18+
CREATE TABLE `DewarRegistry_has_Proposal` (
19+
`dewarRegistryHasProposalId` int(11) unsigned NOT NULL AUTO_INCREMENT,
20+
`dewarRegistryId` int(11) unsigned DEFAULT NULL,
21+
`proposalId` int(10) unsigned DEFAULT NULL,
22+
`personId` int(10) unsigned DEFAULT NULL COMMENT 'Person registering the dewar',
23+
`recordTimestamp` datetime DEFAULT current_timestamp(),
24+
`labContactId` int(11) unsigned DEFAULT NULL COMMENT 'Owner of the dewar',
25+
PRIMARY KEY (`dewarRegistryHasProposalId`),
26+
UNIQUE KEY `dewarRegistryId` (`dewarRegistryId`,`proposalId`),
27+
KEY `DewarRegistry_has_Proposal_ibfk2` (`proposalId`),
28+
KEY `DewarRegistry_has_Proposal_ibfk3` (`personId`),
29+
KEY `DewarRegistry_has_Proposal_ibfk4` (`labContactId`),
30+
CONSTRAINT `DewarRegistry_has_Proposal_ibfk1` FOREIGN KEY (`dewarRegistryId`) REFERENCES `DewarRegistry` (`dewarRegistryId`),
31+
CONSTRAINT `DewarRegistry_has_Proposal_ibfk2` FOREIGN KEY (`proposalId`) REFERENCES `Proposal` (`proposalId`),
32+
CONSTRAINT `DewarRegistry_has_Proposal_ibfk3` FOREIGN KEY (`personId`) REFERENCES `Person` (`personId`),
33+
CONSTRAINT `DewarRegistry_has_Proposal_ibfk4` FOREIGN KEY (`labContactId`) REFERENCES `LabContact` (`labContactId`) ON DELETE NO ACTION ON UPDATE CASCADE
34+
);
35+
36+
UPDATE SchemaStatus SET schemaStatus = 'DONE' WHERE scriptName = '2020_09_09_DewarRegistry_tables.sql';

0 commit comments

Comments
 (0)