@@ -299,6 +299,7 @@ CREATE TABLE `physiological_task_event` (
299299 ` InsertTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
300300 ` Onset` DECIMAL (11 ,6 ) NOT NULL ,
301301 ` Duration` DECIMAL (11 ,6 ) NOT NULL ,
302+ ` Channel` TEXT DEFAULT NULL ,
302303 ` EventCode` INT (10 ) DEFAULT NULL ,
303304 ` EventValue` varchar (255 ) DEFAULT NULL ,
304305 ` EventSample` decimal (11 ,6 ) DEFAULT NULL ,
@@ -577,14 +578,16 @@ CREATE TABLE `physiological_task_event_hed_rel` (
577578 ` HasPairing` boolean DEFAULT FALSE, -- Is grouped with #AdditionalMembers# members
578579 ` PairRelID` int (10 ) unsigned NULL , -- The `ID` of right side of the pair
579580 ` AdditionalMembers` int (10 ) unsigned DEFAULT 0 , -- Number of additional members to encapsulate
581+ ` TaggedBy` int (10 ) unsigned DEFAULT NULL ,
580582 PRIMARY KEY (` ID` ),
581583 CONSTRAINT ` FK_physiological_task_event_hed_rel_pair` FOREIGN KEY (` PairRelID` )
582584 REFERENCES ` physiological_task_event_hed_rel` (` ID` ) ON DELETE CASCADE ON UPDATE CASCADE,
583585 KEY ` FK_physiological_task_event_hed_rel_2` (` HEDTagID` ),
584586 CONSTRAINT ` FK_physiological_task_event_hed_rel_2` FOREIGN KEY (` HEDTagID` )
585587 REFERENCES ` hed_schema_nodes` (` ID` ) ON DELETE CASCADE ON UPDATE CASCADE,
586588 CONSTRAINT ` FK_physiological_task_event_hed_rel_1` FOREIGN KEY (` PhysiologicalTaskEventID` )
587- REFERENCES ` physiological_task_event` (` PhysiologicalTaskEventID` ) ON DELETE CASCADE ON UPDATE CASCADE
589+ REFERENCES ` physiological_task_event` (` PhysiologicalTaskEventID` ) ON DELETE CASCADE ON UPDATE CASCADE,
590+ CONSTRAINT ` FK_pte_tagged_by_user` FOREIGN KEY (` TaggedBy` ) REFERENCES ` users` (` ID` )
588591) ENGINE= InnoDB DEFAULT CHARSET= utf8;
589592
590593-- Create `bids_event_dataset_mapping` table
@@ -599,10 +602,12 @@ CREATE TABLE `bids_event_dataset_mapping` (
599602 ` HasPairing` BOOLEAN DEFAULT FALSE, -- Is grouped with #AdditionalMembers# members
600603 ` PairRelID` int (10 ) unsigned NULL , -- The `ID` of right side of the pair
601604 ` AdditionalMembers` int (10 ) unsigned DEFAULT 0 , -- Number of additional members to encapsulate
605+ ` TaggedBy` int (10 ) unsigned DEFAULT NULL ,
602606 PRIMARY KEY (` ID` ),
603607 INDEX idx_event_dataset_PropertyName_PropertyValue (` PropertyName` , ` PropertyValue` ),
604608 CONSTRAINT ` FK_project_id` FOREIGN KEY (` ProjectID` ) REFERENCES ` Project` (` ProjectID` ) ON DELETE CASCADE ON UPDATE CASCADE,
605- CONSTRAINT ` FK_dataset_hed_tag_id` FOREIGN KEY (` HEDTagID` ) REFERENCES ` hed_schema_nodes` (` ID` ) ON DELETE CASCADE ON UPDATE CASCADE
609+ CONSTRAINT ` FK_dataset_hed_tag_id` FOREIGN KEY (` HEDTagID` ) REFERENCES ` hed_schema_nodes` (` ID` ) ON DELETE CASCADE ON UPDATE CASCADE,
610+ CONSTRAINT ` FK_bed_tagged_by_user` FOREIGN KEY (` TaggedBy` ) REFERENCES ` users` (` ID` )
606611) ENGINE= InnoDB DEFAULT CHARSET= utf8;
607612
608613
@@ -618,8 +623,143 @@ CREATE TABLE `bids_event_file_mapping` (
618623 ` HasPairing` BOOLEAN DEFAULT FALSE, -- Is grouped with #AdditionalMembers# members
619624 ` PairRelID` int (10 ) unsigned NULL , -- The `ID` of right side of the pair
620625 ` AdditionalMembers` int (10 ) unsigned DEFAULT 0 , -- Number of additional members to encapsulate
626+ ` TaggedBy` int (10 ) unsigned DEFAULT NULL ,
621627 PRIMARY KEY (` ID` ),
622628 INDEX idx_event_file_PropertyName_PropertyValue (` PropertyName` , ` PropertyValue` ),
623629 CONSTRAINT ` FK_event_mapping_file_id` FOREIGN KEY (` EventFileID` ) REFERENCES ` physiological_event_file` (` EventFileID` ) ON DELETE CASCADE ON UPDATE CASCADE,
624- CONSTRAINT ` FK_file_hed_tag_id` FOREIGN KEY (` HEDTagID` ) REFERENCES ` hed_schema_nodes` (` ID` ) ON DELETE CASCADE ON UPDATE CASCADE
630+ CONSTRAINT ` FK_file_hed_tag_id` FOREIGN KEY (` HEDTagID` ) REFERENCES ` hed_schema_nodes` (` ID` ) ON DELETE CASCADE ON UPDATE CASCADE,
631+ CONSTRAINT ` FK_bef_tagged_by_user` FOREIGN KEY (` TaggedBy` ) REFERENCES ` users` (` ID` )
625632) ENGINE= InnoDB DEFAULT CHARSET= utf8;
633+
634+
635+ -- Create parameter_project table to track channel delimiter
636+ CREATE TABLE `parameter_project ` (
637+ ` ParameterProjectID` int (10 ) unsigned NOT NULL auto_increment,
638+ ` ProjectID` int (10 ) unsigned NOT NULL default ' 0' ,
639+ ` ParameterTypeID` int (10 ) unsigned NOT NULL default ' 0' ,
640+ ` Value` varchar (255 ) default NULL ,
641+ ` InsertTime` int (10 ) unsigned NOT NULL default ' 0' ,
642+ PRIMARY KEY (` ParameterProjectID` ),
643+ UNIQUE KEY ` project_type` (` ProjectID` ,` ParameterTypeID` ),
644+ KEY ` parameter_value` (` ParameterTypeID` ,` Value` (64 )),
645+ CONSTRAINT ` FK_parameter_project_2` FOREIGN KEY (` ParameterTypeID` ) REFERENCES ` parameter_type` (` ParameterTypeID` ),
646+ CONSTRAINT ` FK_parameter_project_1` FOREIGN KEY (` ProjectID` ) REFERENCES ` Project` (` ProjectID` ) ON DELETE CASCADE ON UPDATE CASCADE
647+ ) ENGINE= InnoDB DEFAULT CHARSET= utf8;
648+
649+ INSERT IGNORE INTO ` parameter_type_category` (Name, Type)
650+ VALUES (' Project Parameters' , ' Metavars' );
651+
652+ -- Add channel delimiter, taken from events.json to DB
653+ INSERT IGNORE INTO parameter_type (Name, Type, Description, SourceFrom, Queryable, IsFile) VALUES
654+ (' ChannelDelimiter' , ' text' , ' Channel name separator' , ' parameter_project' , 1 , 0 );
655+
656+ INSERT INTO parameter_type_category_rel (ParameterTypeID, ParameterTypeCategoryID)
657+ SELECT pt .ParameterTypeID , ptc .ParameterTypeCategoryID
658+ FROM parameter_type pt, parameter_type_category ptc
659+ WHERE ptc .Name = ' Project Parameters' AND pt .Name IN (' ChannelDelimiter' );
660+
661+
662+
663+ -- Create `hed_tag_endorsement` table
664+ CREATE TABLE `hed_tag_endorsement ` (
665+ ` ID` int (10 ) unsigned NOT NULL AUTO_INCREMENT,
666+ ` HEDRelID` int (10 ) unsigned NOT NULL , -- TODO: Manually handle ON DELETE CASCADE
667+ ` HEDTable` enum(
668+ ' physiological_task_event_hed_rel' ,
669+ ' bids_event_dataset_mapping' ,
670+ ' bids_event_file_mapping'
671+ ) NOT NULL ,
672+ ` EndorsedBy` int (10 ) unsigned NOT NULL ,
673+ ` EndorsementStatus` enum(
674+ ' Endorsed' ,
675+ ' Caveat' ,
676+ ' Comment'
677+ ) NOT NULL ,
678+ ` EndorsementComment` TEXT DEFAULT NULL ,
679+ ` EndorsedAt` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
680+ ` LastUpdate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
681+ PRIMARY KEY (` ID` ),
682+ CONSTRAINT ` FK_endorsed_by_user`
683+ FOREIGN KEY (` EndorsedBy` ) REFERENCES ` users` (` ID` ) ON UPDATE CASCADE ON DELETE CASCADE
684+ ) ENGINE= InnoDB DEFAULT CHARSET= utf8mb4;
685+
686+ -- Create `hed_tag_endorsement_history` table
687+ CREATE TABLE `hed_tag_endorsement_history ` (
688+ ` ID` int (10 ) unsigned NOT NULL AUTO_INCREMENT,
689+ ` EndorsementID` int (10 ) unsigned NOT NULL ,
690+ ` Action` enum(
691+ ' INSERT' ,
692+ ' UPDATE' ,
693+ ' DELETE'
694+ ) NOT NULL ,
695+ ` HEDRelID` int (10 ) unsigned NOT NULL ,
696+ ` HEDTable` enum(
697+ ' physiological_task_event_hed_rel' ,
698+ ' bids_event_dataset_mapping' ,
699+ ' bids_event_file_mapping'
700+ ) NOT NULL ,
701+ ` EndorsedBy` int (10 ) unsigned NOT NULL ,
702+ ` EndorsementStatus` enum(
703+ ' Endorsed' ,
704+ ' Caveat' ,
705+ ' Comment'
706+ ) NOT NULL ,
707+ ` EndorsementComment` TEXT DEFAULT NULL ,
708+ ` EndorsedAt` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
709+ PRIMARY KEY (` ID` ),
710+ CONSTRAINT ` FK_endorsement_id`
711+ FOREIGN KEY (` EndorsementID` ) REFERENCES ` hed_tag_endorsement` (` ID` ) ON UPDATE CASCADE,
712+ CONSTRAINT ` FK_endorsed_by_user_history`
713+ FOREIGN KEY (` EndorsedBy` ) REFERENCES ` users` (` ID` ) ON UPDATE CASCADE ON DELETE CASCADE
714+ ) ENGINE= InnoDB DEFAULT CHARSET= utf8mb4;
715+
716+ -- Create `hed_tag_history` table
717+ CREATE TABLE `hed_tag_history ` (
718+ ` ID` int (10 ) unsigned NOT NULL AUTO_INCREMENT,
719+ ` HEDTableID` int (10 ) unsigned NOT NULL ,
720+ ` HEDTable` enum(
721+ ' physiological_task_event_hed_rel' ,
722+ ' bids_event_dataset_mapping' ,
723+ ' bids_event_file_mapping'
724+ ) NOT NULL ,
725+ ` HEDReferenceID` int (10 ) unsigned NOT NULL , -- PhysiologicalTaskEventID, ProjectID, EventFileID
726+ ` TaggedBy` int (10 ) unsigned DEFAULT NULL ,
727+ ` PropertyName` varchar (50 ) DEFAULT NULL ,
728+ ` PropertyValue` varchar (255 ) DEFAULT NULL ,
729+ ` HEDTagID` int (10 ) unsigned DEFAULT NULL , -- Reference to hed_schema_nodes.ID. Can be null to only add parentheses
730+ ` TagValue` TEXT NULL ,
731+ ` Description` TEXT NULL ,
732+ ` HasPairing` BOOLEAN DEFAULT FALSE, -- Is grouped with #AdditionalMembers# members
733+ ` PairRelID` int (10 ) unsigned NULL , -- The `ID` of right side of the pair
734+ ` AdditionalMembers` int (10 ) unsigned DEFAULT 0 ,
735+ ` ModificationType` enum(' insert' , ' update' , ' delete' ) NOT NULL ,
736+ ` ModifiedAt` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
737+ PRIMARY KEY (` ID` ),
738+ CONSTRAINT ` FK_hed_tagged_by_history`
739+ FOREIGN KEY (` TaggedBy` ) REFERENCES ` users` (` ID` ) ON UPDATE CASCADE
740+ ) ENGINE= InnoDB DEFAULT CHARSET= utf8mb4;
741+
742+ -- Create `physiological_task_event_history` table
743+ CREATE TABLE `physiological_task_event_history ` (
744+ ` ID` int (10 ) unsigned NOT NULL AUTO_INCREMENT,
745+ ` PhysiologicalTaskEventID` int (10 ) unsigned NOT NULL ,
746+ ` PhysiologicalFileID` int (10 ) unsigned NOT NULL ,
747+ ` EventFileID` int (10 ) unsigned NOT NULL ,
748+ ` InsertTime` timestamp NOT NULL ,
749+ ` Onset` decimal (11 ,6 ) DEFAULT NULL ,
750+ ` Duration` decimal (11 ,6 ) DEFAULT NULL ,
751+ ` Channel` TEXT DEFAULT NULL ,
752+ ` EventCode` int (10 ) DEFAULT NULL ,
753+ ` EventValue` varchar (255 ) DEFAULT NULL ,
754+ ` EventSample` decimal (11 ,6 ) DEFAULT NULL ,
755+ ` EventType` varchar (50 ) DEFAULT NULL ,
756+ ` TrialType` varchar (255 ) DEFAULT NULL ,
757+ ` ResponseTime` time DEFAULT NULL ,
758+ ` ModifiedBy` int (10 ) unsigned DEFAULT NULL ,
759+ ` ModificationType` enum(' insert' , ' update' , ' delete' ) NOT NULL ,
760+ ` ModifiedAt` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
761+ PRIMARY KEY (` ID` ),
762+ CONSTRAINT ` FK_physiological_task_event_modified_by_history`
763+ FOREIGN KEY (` ModifiedBy` ) REFERENCES ` users` (` ID` ) ON UPDATE CASCADE
764+ ) ENGINE= InnoDB DEFAULT CHARSET= utf8mb4;
765+
0 commit comments