Skip to content

Commit

Permalink
[flag] Add flag editors table
Browse files Browse the repository at this point in the history
  • Loading branch information
skarya22 committed Nov 18, 2024
1 parent 4f15b00 commit bdea17c
Show file tree
Hide file tree
Showing 4 changed files with 11,256 additions and 5,608 deletions.
19 changes: 17 additions & 2 deletions SQL/0000-00-00-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ CREATE TABLE `flag` (
`Administration` enum('None','Partial','All') default NULL,
`Validity` enum('Questionable','Invalid','Valid') default NULL,
`Exclusion` enum('Fail','Pass') default NULL,
`UserID` varchar(255) default NULL,
`Testdate` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`DataID` int(10) unsigned default NULL,
PRIMARY KEY (`CommentID`),
Expand All @@ -309,12 +308,28 @@ CREATE TABLE `flag` (
KEY `flag_Data_entry` (`Data_entry`),
KEY `flag_Validity` (`Validity`),
KEY `flag_Administration` (`Administration`),
KEY `flag_UserID` (`UserID`),
CONSTRAINT `FK_flag_1` FOREIGN KEY (`SessionID`) REFERENCES `session` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `FK_flag_3` FOREIGN KEY (`DataID`) REFERENCES `instrument_data` (`ID`),
CONSTRAINT `FK_ibfk_1` FOREIGN KEY (`TestID`) REFERENCES `test_names` (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `flag_editors` (
`userID` int(10) unsigned NOT NULL default '0',
`CommentID` VARCHAR(255) NOT NULL default '',
PRIMARY KEY (`userID`,`CommentID`),
KEY `FK_flag_editors_2` (`CommentID`),
CONSTRAINT `FK_flag_editors_2`
FOREIGN KEY (`CommentID`)
REFERENCES `flag` (`CommentID`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `FK_flag_editors_1`
FOREIGN KEY (`userID`)
REFERENCES `users` (`ID`)
ON DELETE CASCADE
ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `history` (
`id` int(11) NOT NULL auto_increment,
`tbl` varchar(255) NOT NULL default '',
Expand Down
21 changes: 21 additions & 0 deletions SQL/New_patches/2024_11_18_Save_Flag_Editors.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
CREATE TABLE `flag_editors` (
`userID` int(10) unsigned NOT NULL default '0',
`CommentID` VARCHAR(255) NOT NULL default '',
PRIMARY KEY (`userID`,`CommentID`),
KEY `FK_flag_editors_2` (`CommentID`),
CONSTRAINT `FK_flag_editors_2`
FOREIGN KEY (`CommentID`)
REFERENCES `flag` (`CommentID`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `FK_flag_editors_1`
FOREIGN KEY (`userID`)
REFERENCES `users` (`ID`)
ON DELETE CASCADE
ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO flag_editors (UserID, CommentID)
SELECT users.ID, CommentID from flag JOIN users ON flag.UserID = users.UserID;

ALTER TABLE flag DROP COLUMN UserID;
Loading

0 comments on commit bdea17c

Please sign in to comment.