-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Hôte : 127.0.0.1
-- Généré le : lun. 18 sep. 2023 à 14:10
-- Version du serveur : 10.4.27-MariaDB
-- Version de PHP : 8.2.0

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Base de données : `proserveapi`
--
DROP DATABASE IF EXISTS proserveapi;
CREATE DATABASE proserveapi;
USE proserveapi;

-- --------------------------------------------------------

--
-- Structure de la table `participates`
--

CREATE TABLE `participates` (
  `userId` int(11) NOT NULL COMMENT 'user id',
  `sessionId` int(11) NOT NULL COMMENT 'session id',
  `score` int(11) NOT NULL DEFAULT 0 COMMENT 'user score in the session',
  `firePrecision` float NOT NULL DEFAULT 0 COMMENT 'user precision during the session',
  `reactionTime` float NOT NULL DEFAULT 0 COMMENT 'average reaction time of the user in this session',
  `nbEnemyHit` int(11) NOT NULL DEFAULT 0 COMMENT 'nb of enemies hit',
  `nbCivilsHit` int(11) NOT NULL DEFAULT 0 COMMENT 'nb of civils hit',
  `damageTaken` int(11) NOT NULL DEFAULT 0 COMMENT 'nb hits received',
  `endStatus` int(1) NOT NULL DEFAULT 1 COMMENT 'user status at the end of the session (0=>dead, 1=>alive, add 2 for injured ?)',
  `avatar` varchar(255) NOT NULL COMMENT 'avatar of user for this session',
  `weapon` varchar(255) NOT NULL COMMENT 'weapon of user for this session',
  `role` int(11) NOT NULL DEFAULT 0 COMMENT 'user role in the session',
  `results` text NOT NULL DEFAULT '\'\'' COMMENT 'user''s results (objectives) in session (JSON format)'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `reacteventmodes`
--

CREATE TABLE `reacteventmodes` (
  `id` int(11) NOT NULL COMMENT 'id',
  `displayName` varchar(255) NOT NULL COMMENT 'name',
  `description` varchar(255) NOT NULL COMMENT 'description'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Déchargement des données de la table `reacteventmodes`
--

INSERT INTO `reacteventmodes` (`id`, `displayName`, `description`) VALUES
(0, 'Penetration', ''),
(1, 'Ricochet', ''),
(2, 'Termination', '');

-- --------------------------------------------------------

--
-- Structure de la table `reactevents`
--

CREATE TABLE `reactevents` (
  `id` int(11) NOT NULL COMMENT 'event id',
  `srcEventSessionId` int(11) NOT NULL COMMENT 'session id',
  `srcEventIndex` int(11) NOT NULL COMMENT 'id of the triggering event that initiated this reaction event',
  `reactType` int(11) NOT NULL COMMENT 'react event type',
  `reactMode` int(11) NOT NULL DEFAULT 0 COMMENT 'react event mode (penetration, ricochet, termination)',
  `hitUserId` int(11) NOT NULL DEFAULT 0 COMMENT 'id of the user that has been hit (0 if enemy/civil/env/game)',
  `hitTargetName` varchar(255) NOT NULL COMMENT 'target hit by the event',
  `hitBoneName` varchar(255) NOT NULL COMMENT 'bone hit on the target',
  `damage` float NOT NULL DEFAULT 0 COMMENT 'damage points for the event',
  `targetKilled` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'did target got killed by the event ?',
  `objectHitLocationX` float NOT NULL DEFAULT 0 COMMENT 'when hitting a target (object) record X position on texture',
  `objectHitLocationY` float NOT NULL DEFAULT 0 COMMENT 'when hitting a target (object) record Y position on texture',
  `objectHitTagLocation` varchar(255) NOT NULL COMMENT 'tag on the hit object',
  `hitPrecision` float NOT NULL DEFAULT 1 COMMENT 'precision of the hit',
  `distance` float NOT NULL DEFAULT 0 COMMENT 'distance from source to target hit',
  `reactTime` float NOT NULL DEFAULT 0 COMMENT 'reaction time (for challenges)',
  `timeStamp` float NOT NULL DEFAULT 0 COMMENT 'timeStamp react shot was registered'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `reacteventtypes`
--

CREATE TABLE `reacteventtypes` (
  `id` int(11) NOT NULL COMMENT 'type id',
  `displayName` varchar(255) NOT NULL COMMENT 'name',
  `description` varchar(255) NOT NULL COMMENT 'description'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Déchargement des données de la table `reacteventtypes`
--

INSERT INTO `reacteventtypes` (`id`, `displayName`, `description`) VALUES
(0, 'EnemyHit', 'An enemy has been hit'),
(1, 'CivilianHit', 'A civilian has been hit'),
(2, 'PoliceHit', 'Another player has been hit by himself'),
(3, 'ObjectHit', 'A target (object) has been hit'),
(4, 'PaperTargetHit', ''),
(5, 'TargetHit', ''),
(6, 'DeadBodyHit', 'An already-dead body has been hit');

-- --------------------------------------------------------

--
-- Doublure de structure pour la vue `sessiondebriefs`
-- (Voir ci-dessous la vue réelle)
--
CREATE TABLE `sessiondebriefs` (
`SessionId` int(11)
,`SessionTypeId` int(11)
,`SessionType` varchar(255)
,`SessionName` varchar(255)
,`SessionDate` datetime
,`MapName` varchar(255)
,`ScenarioName` varchar(255)
,`SessionSuccessful` tinyint(1)
,`SessionDuration` float
,`TriggerTypeId` int(11)
,`TriggerType` varchar(255)
,`ShooterId` int(11)
,`ShooterName` varchar(255)
,`ShooterRoleId` int(11)
,`ShooterRole` varchar(255)
,`ShotIndex` int(11)
,`ReactId` int(11)
,`ReactModeId` int(11)
,`ReactMode` varchar(255)
,`ReactTypeId` int(11)
,`ReactType` varchar(255)
,`TargetUserId` int(11)
,`TargetUserName` varchar(255)
,`TargetRoleId` int(11)
,`TargetRole` varchar(255)
,`TargetName` varchar(255)
,`TargetBoneName` varchar(255)
,`TargetKilled` int(4)
,`HitLocationX` double
,`HitLocationY` double
,`HitLocationTag` varchar(255)
,`HitPrecision` double
,`HitTargetDistance` double
,`ReactionTime` double
,`TimeStamp` double
,`NbHit` bigint(21)
,`NbKilled` bigint(21)
);

-- --------------------------------------------------------

--
-- Structure de la table `sessions`
--

CREATE TABLE `sessions` (
  `id` int(11) NOT NULL COMMENT 'session id',
  `sessionType` int(11) NOT NULL COMMENT 'session type',
  `sessionName` varchar(255) NOT NULL COMMENT 'session name',
  `sessionDate` datetime NOT NULL DEFAULT current_timestamp() COMMENT 'date/time of the session',
  `mapName` varchar(255) NOT NULL COMMENT 'map of the session',
  `scenarioName` varchar(255) NOT NULL COMMENT 'scenario name that was played',
  `success` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'was the session successful (scenario objective reached) ?',
  `timeToFinish` float NOT NULL DEFAULT 0 COMMENT 'session duration',
  `score` int(11) NOT NULL DEFAULT 0 COMMENT 'user score',
  `nbEnemyHit` int(11) NOT NULL DEFAULT 0 COMMENT 'nb of enemies hit',
  `nbCivilsHit` int(11) NOT NULL DEFAULT 0 COMMENT 'nb of civils saved',
  `damageTaken` float NOT NULL DEFAULT 0 COMMENT 'total damage taken',
  `replayFileName` varchar(255) NOT NULL COMMENT 'filename of the session replay'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `sessiontypes`
--

CREATE TABLE `sessiontypes` (
  `id` int(11) NOT NULL COMMENT 'session type id',
  `displayName` varchar(255) NOT NULL COMMENT 'displayed name of the session type',
  `description` varchar(255) NOT NULL COMMENT 'description of the session type'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Déchargement des données de la table `sessiontypes`
--

INSERT INTO `sessiontypes` (`id`, `displayName`, `description`) VALUES
(0, 'FireRange', ''),
(1, 'Challenge', ''),
(2, 'Protect', ''),
(3, 'De-Escalation', ''),
(4, 'Terrorism', ''),
(5, 'FireExtinction', ''),
(6, 'Recovering', '');

-- --------------------------------------------------------

--
-- Structure de la table `triggerevents`
--

CREATE TABLE `triggerevents` (
  `sessionId` int(11) NOT NULL COMMENT 'id of the user session during which the event was triggered',
  `indexCount` int(11) NOT NULL COMMENT 'index of event in session',
  `srcUserId` int(11) NOT NULL COMMENT 'id of the user that triggered the shot',
  `type` int(11) NOT NULL COMMENT 'type of event',
  `successful` tinyint(1) NOT NULL COMMENT 'was the shot (or triggered event) successful (hit a target) ?',
  `timeStamp` float NOT NULL COMMENT 'time the event occurred at'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `triggereventtypes`
--

CREATE TABLE `triggereventtypes` (
  `id` int(11) NOT NULL COMMENT 'event type id',
  `displayName` varchar(255) NOT NULL COMMENT 'displayed name of the event type',
  `description` varchar(255) NOT NULL COMMENT 'description of the event type'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Déchargement des données de la table `triggereventtypes`
--

INSERT INTO `triggereventtypes` (`id`, `displayName`, `description`) VALUES
(0, 'Fire', 'Player has fired');

-- --------------------------------------------------------

--
-- Structure de la table `userroles`
--

CREATE TABLE `userroles` (
  `id` int(11) NOT NULL COMMENT 'session type id',
  `displayName` varchar(255) NOT NULL COMMENT 'displayed name of the session type',
  `description` varchar(255) NOT NULL COMMENT 'description of the session type'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Déchargement des données de la table `userroles`
--

INSERT INTO `userroles` (`id`, `displayName`, `description`) VALUES
(0, 'Police', 'Player is Police/SWAT'),
(1, 'Enemy', 'Player is an Enemy'),
(2, 'Civil', 'Player is a Civilian'),
(3, 'IA', 'Role for IA and NPC');

-- --------------------------------------------------------

--
-- Structure de la table `users`
--

CREATE TABLE `users` (
  `id` int(11) NOT NULL COMMENT 'user id',
  `username` varchar(255) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL COMMENT 'username',
  `password` varchar(255) NOT NULL COMMENT 'password',
  `firstName` varchar(255) NOT NULL COMMENT 'first name',
  `lastName` varchar(255) NOT NULL COMMENT 'last name',
  `created` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'date/time of the creation of the user account',
  `leftHanded` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'is user left handed?',
  `maleGender` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'is user a man (true) or a woman?',
  `charSkinAssetName` varchar(255) NOT NULL COMMENT 'name of the asset for the character skin',
  `weaponAssetName` varchar(255) NOT NULL COMMENT 'name of the asset for the weapon',
  `lastConnection` datetime NOT NULL DEFAULT current_timestamp() COMMENT 'date/time of the last connection',
  `avgPrecision` float NOT NULL COMMENT 'average precision when firing',
  `avgReaction` float NOT NULL COMMENT 'average reaction time',
  `avgFault` float NOT NULL COMMENT 'average error rate',
  `avgRapidity` float NOT NULL COMMENT 'average rapidity time',
  `size` int(6) NOT NULL DEFAULT 175
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;


INSERT INTO `users` (`id`, `username`, `password`, `firstName`, `lastName`, `created`, `leftHanded`, `maleGender`, `charSkinAssetName`, `weaponAssetName`, `lastConnection`, `avgPrecision`, `avgReaction`, `avgFault`, `avgRapidity`, `size`) VALUES
(0, 'game', '', '', '', '2023-01-24 10:52:35', 0, 0, '', '', '2023-01-24 11:52:35', 0, 0, 0, 0, 0);

-- --------------------------------------------------------

--
-- Structure de la table `userstatus`
--

CREATE TABLE `userstatus` (
  `id` int(11) NOT NULL COMMENT 'status id',
  `displayName` varchar(255) NOT NULL COMMENT 'display name for status (alive, dead)',
  `description` varchar(255) NOT NULL COMMENT 'description'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Déchargement des données de la table `userstatus`
--

INSERT INTO `userstatus` (`id`, `displayName`, `description`) VALUES
(0, 'Alive', 'avatar is alive'),
(1, 'Lightly Injured', 'avatar has been slightly injured'),
(2, 'Seriously Injured', 'avatar has been seriously injured'),
(3, 'Dead', 'avatar is dead');

-- --------------------------------------------------------

--
-- Structure de la vue `sessiondebriefs`
--
DROP TABLE IF EXISTS `sessiondebriefs`;

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `sessiondebriefs` AS
SELECT
    `s`.`id`              AS `SessionId`,
    `s`.`sessionType`     AS `SessionTypeId`,
    `st`.`displayName`    AS `SessionType`,
    `s`.`sessionName`     AS `SessionName`,
    `s`.`sessionDate`     AS `SessionDate`,
    `s`.`mapName`         AS `MapName`,
    `s`.`scenarioName`    AS `ScenarioName`,
    `s`.`success`         AS `SessionSuccessful`,
    `s`.`timeToFinish`    AS `SessionDuration`,
    COALESCE(`t`.`type`, -1)                  AS `TriggerTypeId`,
    COALESCE(`tt`.`displayName`, '')          AS `TriggerType`,
    IFNULL(`t`.`srcUserId`, `ps`.`userId`)    AS `ShooterId`,
    `us`.`username`                           AS `ShooterName`,
    IFNULL(`ps`.`role`, 3)                    AS `ShooterRoleId`,
    `urs`.`displayName`                       AS `ShooterRole`,
    COALESCE(`t`.`indexCount`, -1)            AS `ShotIndex`,
    COALESCE(`r`.`id`, -1)                    AS `ReactId`,
    COALESCE(`r`.`reactMode`, 2)              AS `ReactModeId`,
    COALESCE(`rm`.`displayName`, '')          AS `ReactMode`,
    COALESCE(`r`.`reactType`, -1)             AS `ReactTypeId`,
    COALESCE(`rt`.`displayName`, '')          AS `ReactType`,
    COALESCE(`r`.`hitUserId`, -1)             AS `TargetUserId`,
    COALESCE(`uh`.`username`, '')             AS `TargetUserName`,
    IFNULL(`ph`.`role`, 3)                    AS `TargetRoleId`,
    `urt`.`displayName`                       AS `TargetRole`,
    COALESCE(`r`.`hitTargetName`, '')         AS `TargetName`,
    COALESCE(`r`.`hitBoneName`, '')           AS `TargetBoneName`,
    COALESCE(`r`.`targetKilled`, 0)           AS `TargetKilled`,
    COALESCE(`r`.`objectHitLocationX`, 0)     AS `HitLocationX`,
    COALESCE(`r`.`objectHitLocationY`, 0)     AS `HitLocationY`,
    COALESCE(`r`.`objectHitTagLocation`, '')  AS `HitLocationTag`,
    COALESCE(`r`.`hitPrecision`, 0)           AS `HitPrecision`,
    COALESCE(`r`.`distance`, 0)               AS `HitTargetDistance`,
    COALESCE(`r`.`reactTime`, 0)              AS `ReactionTime`,
    COALESCE(`r`.`timeStamp`, 0)              AS `TimeStamp`,
    COUNT(DISTINCT `r`.`id`)                  AS `NbHit`,
    COUNT(DISTINCT `rk`.`srcEventIndex`, `rk`.`hitTargetName`) AS `NbKilled`
FROM `sessions` `s`
LEFT JOIN `participates`      `ps`  ON (`s`.`id` = `ps`.`sessionId`)
LEFT JOIN `participates`      `ph`  ON (`s`.`id` = `ph`.`sessionId`)
LEFT JOIN `triggerevents`     `t`   ON (`s`.`id` = `t`.`sessionId`)
LEFT JOIN `triggereventtypes` `tt`  ON (`tt`.`id` = `t`.`type`)
LEFT JOIN `sessiontypes`      `st`  ON (`st`.`id` = `s`.`sessionType`)
LEFT JOIN `reactevents`       `r`   ON (`t`.`indexCount` = `r`.`srcEventIndex` AND `t`.`sessionId` = `r`.`srcEventSessionId`)
LEFT JOIN `users`             `uh`  ON (`uh`.`id` = `r`.`hitUserId`)
LEFT JOIN `users`             `us`  ON (`us`.`id` = `t`.`srcUserId` OR `us`.`id` = `ps`.`userId`)
LEFT JOIN `reacteventtypes`   `rt`  ON (`rt`.`id` = `r`.`reactType`)
LEFT JOIN `reacteventmodes`   `rm`  ON (`rm`.`id` = COALESCE(`r`.`reactMode`, 2))
LEFT JOIN `reactevents`       `rk`  ON (`r`.`id` = `rk`.`id` AND `rk`.`targetKilled` = 1)
LEFT JOIN `userroles`         `urs` ON (`urs`.`id` = IFNULL(`ps`.`role`, 3))
LEFT JOIN `userroles`         `urt` ON (`urt`.`id` = IFNULL(`ph`.`role`, 3))
GROUP BY `SessionId`, `ShooterId`, `ShotIndex`, `TargetName`
ORDER BY `SessionId`, `ShooterId`, `ShotIndex`, `ReactId`;

--
-- Index pour les tables déchargées
--

--
-- Index pour la table `participates`
--
ALTER TABLE `participates`
  ADD PRIMARY KEY (`userId`,`sessionId`),
  ADD KEY `FK_Participates_SessionId` (`sessionId`),
  ADD KEY `FK_Participates_UserStatus` (`endStatus`),
  ADD KEY `FK_Participates_UserRole` (`role`);

--
-- Index pour la table `reacteventmodes`
--
ALTER TABLE `reacteventmodes`
  ADD PRIMARY KEY (`id`);

--
-- Index pour la table `reactevents`
--
ALTER TABLE `reactevents`
  ADD PRIMARY KEY (`id`),
  ADD KEY `FK_React_TypeId` (`reactType`),
  ADD KEY `FK_React_HitUserId` (`hitUserId`),
  ADD KEY `FK_React_EventIndex` (`srcEventIndex`),
  ADD KEY `FK_React_SessionId` (`srcEventSessionId`),
  ADD KEY `FK_React_Mode` (`reactMode`);

--
-- Index pour la table `reacteventtypes`
--
ALTER TABLE `reacteventtypes`
  ADD PRIMARY KEY (`id`);

--
-- Index pour la table `sessions`
--
ALTER TABLE `sessions`
  ADD PRIMARY KEY (`id`),
  ADD KEY `FK_sessionType` (`sessionType`) USING BTREE;

--
-- Index pour la table `sessiontypes`
--
ALTER TABLE `sessiontypes`
  ADD PRIMARY KEY (`id`);

--
-- Index pour la table `triggerevents`
--
ALTER TABLE `triggerevents`
  ADD PRIMARY KEY (`indexCount`,`sessionId`),
  ADD KEY `FK_TriggerEvent_SrcUserId` (`srcUserId`),
  ADD KEY `FK_TriggerEvent_Type` (`type`),
  ADD KEY `FK_TriggerEvent_UserId` (`sessionId`);

--
-- Index pour la table `triggereventtypes`
--
ALTER TABLE `triggereventtypes`
  ADD PRIMARY KEY (`id`);

--
-- Index pour la table `userroles`
--
ALTER TABLE `userroles`
  ADD PRIMARY KEY (`id`);

--
-- Index pour la table `users`
--
ALTER TABLE `users`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `username` (`username`);

--
-- Index pour la table `userstatus`
--
ALTER TABLE `userstatus`
  ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT pour les tables déchargées
--

--
-- AUTO_INCREMENT pour la table `reactevents`
--
ALTER TABLE `reactevents`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'event id';

--
-- AUTO_INCREMENT pour la table `sessions`
--
ALTER TABLE `sessions`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'session id';

--
-- AUTO_INCREMENT pour la table `users`
--
ALTER TABLE `users`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'user id';

--
-- Contraintes pour les tables déchargées
--

--
-- Contraintes pour la table `participates`
--
ALTER TABLE `participates`
  ADD CONSTRAINT `FK_Participates_SessionId` FOREIGN KEY (`sessionId`) REFERENCES `sessions` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `FK_Participates_UserId` FOREIGN KEY (`userId`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `FK_Participates_UserRole` FOREIGN KEY (`role`) REFERENCES `userroles` (`id`),
  ADD CONSTRAINT `FK_Participates_UserStatus` FOREIGN KEY (`endStatus`) REFERENCES `userstatus` (`id`);

--
-- Contraintes pour la table `reactevents`
--
ALTER TABLE `reactevents`
  ADD CONSTRAINT `FK_React_HitUserId` FOREIGN KEY (`hitUserId`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `FK_React_Mode` FOREIGN KEY (`reactMode`) REFERENCES `reacteventmodes` (`id`),
  ADD CONSTRAINT `FK_React_SessionId` FOREIGN KEY (`srcEventSessionId`) REFERENCES `sessions` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `FK_React_TypeId` FOREIGN KEY (`reactType`) REFERENCES `reacteventtypes` (`id`);

--
-- Contraintes pour la table `sessions`
--
ALTER TABLE `sessions`
  ADD CONSTRAINT `FK_SessionType` FOREIGN KEY (`sessionType`) REFERENCES `sessiontypes` (`id`);

--
-- Contraintes pour la table `triggerevents`
--
ALTER TABLE `triggerevents`
  ADD CONSTRAINT `FK_TriggerEvent_SrcUserId` FOREIGN KEY (`srcUserId`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `FK_TriggerEvent_Type` FOREIGN KEY (`type`) REFERENCES `triggereventtypes` (`id`),
  ADD CONSTRAINT `FK_TriggerEvent_UserId` FOREIGN KEY (`sessionId`) REFERENCES `sessions` (`id`) ON DELETE CASCADE;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
