-- phpMyAdmin SQL Dump
-- version 4.9.7
-- https://www.phpmyadmin.net/
--
-- Host: 192.168.4.21:3304
-- Generation Time: Aug 06, 2024 at 01:15 AM
-- Server version: 10.11.8-MariaDB-deb12-log
-- PHP Version: 7.4.24

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
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 */;

--
-- Database: `tgs-tgmc`
--
CREATE DATABASE IF NOT EXISTS `tgs-tgmc` DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_bin;
USE `tgs-tgmc`;

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

--
-- Table structure for table `chatbots`
--
-- Creation: Aug 01, 2024 at 12:54 PM
--

CREATE TABLE IF NOT EXISTS `chatbots` (
  `Id` bigint(20) NOT NULL AUTO_INCREMENT,
  `Name` varchar(100) NOT NULL,
  `Enabled` tinyint(1) DEFAULT NULL,
  `Provider` int(11) NOT NULL,
  `ConnectionString` longtext NOT NULL,
  `InstanceId` bigint(20) NOT NULL,
  `ReconnectionInterval` int(10) UNSIGNED NOT NULL DEFAULT 5,
  `ChannelLimit` smallint(5) UNSIGNED NOT NULL DEFAULT 100,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `IX_ChatBots_InstanceId_Name` (`InstanceId`,`Name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin;

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

--
-- Table structure for table `chatchannels`
--
-- Creation: Aug 01, 2024 at 12:54 PM
--

CREATE TABLE IF NOT EXISTS `chatchannels` (
  `IrcChannel` varchar(100) DEFAULT NULL,
  `DiscordChannelId` bigint(20) UNSIGNED DEFAULT NULL,
  `IsAdminChannel` tinyint(1) NOT NULL,
  `IsWatchdogChannel` tinyint(1) NOT NULL,
  `IsUpdatesChannel` tinyint(1) NOT NULL,
  `Tag` longtext DEFAULT NULL,
  `Id` bigint(20) NOT NULL AUTO_INCREMENT,
  `ChatSettingsId` bigint(20) NOT NULL,
  `IsSystemChannel` tinyint(1) NOT NULL DEFAULT 1,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `IX_ChatChannels_ChatSettingsId_DiscordChannelId` (`ChatSettingsId`,`DiscordChannelId`),
  UNIQUE KEY `IX_ChatChannels_ChatSettingsId_IrcChannel` (`ChatSettingsId`,`IrcChannel`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin;

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

--
-- Table structure for table `compilejobs`
--
-- Creation: Aug 05, 2024 at 09:23 AM
-- Last update: Aug 05, 2024 at 10:44 PM
--

CREATE TABLE IF NOT EXISTS `compilejobs` (
  `Id` bigint(20) NOT NULL AUTO_INCREMENT,
  `DmeName` longtext NOT NULL,
  `Output` longtext NOT NULL,
  `DirectoryName` char(36) NOT NULL,
  `JobId` bigint(20) NOT NULL,
  `RevisionInformationId` bigint(20) NOT NULL,
  `EngineVersion` longtext NOT NULL,
  `MinimumSecurityLevel` int(11) DEFAULT NULL,
  `DMApiMajorVersion` int(11) DEFAULT NULL,
  `DMApiMinorVersion` int(11) DEFAULT NULL,
  `DMApiPatchVersion` int(11) DEFAULT NULL,
  `GitHubDeploymentId` bigint(20) DEFAULT NULL,
  `GitHubRepoId` bigint(20) DEFAULT NULL,
  `RepositoryOrigin` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `IX_CompileJobs_JobId` (`JobId`),
  KEY `IX_CompileJobs_DirectoryName` (`DirectoryName`),
  KEY `IX_CompileJobs_RevisionInformationId` (`RevisionInformationId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin;

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

--
-- Table structure for table `dreamdaemonsettings`
--
-- Creation: Aug 05, 2024 at 02:39 AM
-- Last update: Aug 05, 2024 at 02:39 AM
--

CREATE TABLE IF NOT EXISTS `dreamdaemonsettings` (
  `AllowWebClient` tinyint(1) NOT NULL,
  `SecurityLevel` int(11) NOT NULL,
  `Port` smallint(5) UNSIGNED NOT NULL DEFAULT 0,
  `StartupTimeout` int(10) UNSIGNED NOT NULL,
  `AutoStart` tinyint(1) NOT NULL,
  `Id` bigint(20) NOT NULL AUTO_INCREMENT,
  `InstanceId` bigint(20) NOT NULL,
  `HealthCheckSeconds` int(10) UNSIGNED NOT NULL,
  `TopicRequestTimeout` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `AdditionalParameters` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `Visibility` int(11) NOT NULL DEFAULT 0,
  `DumpOnHealthCheckRestart` tinyint(1) NOT NULL,
  `StartProfiler` tinyint(1) NOT NULL DEFAULT 0,
  `LogOutput` tinyint(1) NOT NULL DEFAULT 0,
  `MapThreads` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `Minidumps` tinyint(1) NOT NULL DEFAULT 0,
  `OpenDreamTopicPort` smallint(5) UNSIGNED NOT NULL DEFAULT 0,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `IX_DreamDaemonSettings_InstanceId` (`InstanceId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin;

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

--
-- Table structure for table `dreammakersettings`
--
-- Creation: Aug 01, 2024 at 12:54 PM
--

CREATE TABLE IF NOT EXISTS `dreammakersettings` (
  `ProjectName` longtext DEFAULT NULL,
  `ApiValidationPort` smallint(5) UNSIGNED NOT NULL,
  `Id` bigint(20) NOT NULL AUTO_INCREMENT,
  `InstanceId` bigint(20) NOT NULL,
  `ApiValidationSecurityLevel` int(11) NOT NULL DEFAULT 1,
  `RequireDMApiValidation` tinyint(1) NOT NULL DEFAULT 1,
  `Timeout` time(6) NOT NULL DEFAULT '01:00:00.000000',
  `CompilerAdditionalArguments` varchar(10000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `IX_DreamMakerSettings_InstanceId` (`InstanceId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin;

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

--
-- Table structure for table `groups`
--
-- Creation: Aug 01, 2024 at 12:54 PM
--

CREATE TABLE IF NOT EXISTS `groups` (
  `Id` bigint(20) NOT NULL AUTO_INCREMENT,
  `Name` varchar(100) NOT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `IX_Groups_Name` (`Name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin;

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

--
-- Table structure for table `instancepermissionsets`
--
-- Creation: Aug 01, 2024 at 12:54 PM
--

CREATE TABLE IF NOT EXISTS `instancepermissionsets` (
  `Id` bigint(20) NOT NULL AUTO_INCREMENT,
  `PermissionSetId` bigint(20) NOT NULL,
  `InstancePermissionSetRights` bigint(20) UNSIGNED NOT NULL,
  `EngineRights` bigint(20) UNSIGNED NOT NULL,
  `DreamDaemonRights` bigint(20) UNSIGNED NOT NULL,
  `DreamMakerRights` bigint(20) UNSIGNED NOT NULL,
  `RepositoryRights` bigint(20) UNSIGNED NOT NULL,
  `ChatBotRights` bigint(20) UNSIGNED NOT NULL,
  `ConfigurationRights` bigint(20) UNSIGNED NOT NULL,
  `InstanceId` bigint(20) NOT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `IX_InstancePermissionSets_PermissionSetId_InstanceId` (`PermissionSetId`,`InstanceId`),
  KEY `IX_InstancePermissionSets_InstanceId` (`InstanceId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin;

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

--
-- Table structure for table `instances`
--
-- Creation: Aug 01, 2024 at 12:54 PM
--

CREATE TABLE IF NOT EXISTS `instances` (
  `Id` bigint(20) NOT NULL AUTO_INCREMENT,
  `Name` varchar(100) NOT NULL,
  `Path` varchar(255) NOT NULL,
  `Online` tinyint(1) NOT NULL,
  `ConfigurationType` int(11) NOT NULL,
  `AutoUpdateInterval` int(10) UNSIGNED NOT NULL,
  `ChatBotLimit` smallint(5) UNSIGNED NOT NULL DEFAULT 10,
  `SwarmIdentifer` varchar(255) DEFAULT NULL,
  `AutoUpdateCron` varchar(10000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `IX_Instances_Path_SwarmIdentifer` (`Path`,`SwarmIdentifer`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin;

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

--
-- Table structure for table `jobs`
--
-- Creation: Aug 05, 2024 at 09:23 AM
-- Last update: Aug 05, 2024 at 10:44 PM
--

CREATE TABLE IF NOT EXISTS `jobs` (
  `Id` bigint(20) NOT NULL AUTO_INCREMENT,
  `Description` longtext NOT NULL,
  `ExceptionDetails` longtext DEFAULT NULL,
  `StartedAt` datetime(6) NOT NULL,
  `StoppedAt` datetime(6) DEFAULT NULL,
  `Cancelled` tinyint(1) NOT NULL,
  `CancelRightsType` bigint(20) UNSIGNED DEFAULT NULL,
  `CancelRight` bigint(20) UNSIGNED DEFAULT NULL,
  `StartedById` bigint(20) NOT NULL,
  `CancelledById` bigint(20) DEFAULT NULL,
  `InstanceId` bigint(20) NOT NULL,
  `ErrorCode` int(10) UNSIGNED DEFAULT NULL,
  `JobCode` tinyint(3) UNSIGNED NOT NULL DEFAULT 0,
  PRIMARY KEY (`Id`),
  KEY `IX_Jobs_CancelledById` (`CancelledById`),
  KEY `IX_Jobs_InstanceId` (`InstanceId`),
  KEY `IX_Jobs_StartedById` (`StartedById`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin;

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

--
-- Table structure for table `oauthconnections`
--
-- Creation: Aug 01, 2024 at 12:54 PM
--

CREATE TABLE IF NOT EXISTS `oauthconnections` (
  `Id` bigint(20) NOT NULL AUTO_INCREMENT,
  `Provider` int(11) NOT NULL,
  `ExternalUserId` varchar(100) NOT NULL,
  `UserId` bigint(20) DEFAULT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `IX_OAuthConnections_Provider_ExternalUserId` (`Provider`,`ExternalUserId`),
  KEY `IX_OAuthConnections_UserId` (`UserId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin;

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

--
-- Table structure for table `permissionsets`
--
-- Creation: Aug 01, 2024 at 12:54 PM
--

CREATE TABLE IF NOT EXISTS `permissionsets` (
  `Id` bigint(20) NOT NULL AUTO_INCREMENT,
  `AdministrationRights` bigint(20) UNSIGNED NOT NULL,
  `InstanceManagerRights` bigint(20) UNSIGNED NOT NULL,
  `UserId` bigint(20) DEFAULT NULL,
  `GroupId` bigint(20) DEFAULT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `IX_PermissionSets_GroupId` (`GroupId`),
  UNIQUE KEY `IX_PermissionSets_UserId` (`UserId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin;

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

--
-- Table structure for table `reattachinformations`
--
-- Creation: Aug 01, 2024 at 12:54 PM
-- Last update: Aug 05, 2024 at 11:57 PM
--

CREATE TABLE IF NOT EXISTS `reattachinformations` (
  `AccessIdentifier` longtext NOT NULL,
  `ProcessId` int(11) NOT NULL,
  `Port` smallint(5) UNSIGNED NOT NULL,
  `RebootState` int(11) NOT NULL,
  `Id` bigint(20) NOT NULL AUTO_INCREMENT,
  `CompileJobId` bigint(20) NOT NULL,
  `LaunchSecurityLevel` int(11) NOT NULL DEFAULT 1,
  `LaunchVisibility` int(11) NOT NULL DEFAULT 0,
  `InitialCompileJobId` bigint(20) DEFAULT NULL,
  `TopicPort` smallint(5) UNSIGNED DEFAULT NULL,
  PRIMARY KEY (`Id`),
  KEY `IX_ReattachInformations_CompileJobId` (`CompileJobId`),
  KEY `IX_ReattachInformations_InitialCompileJobId` (`InitialCompileJobId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin;

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

--
-- Table structure for table `repositorysettings`
--
-- Creation: Aug 01, 2024 at 12:54 PM
--

CREATE TABLE IF NOT EXISTS `repositorysettings` (
  `CommitterName` longtext NOT NULL,
  `CommitterEmail` longtext NOT NULL,
  `AccessUser` longtext DEFAULT NULL,
  `AccessToken` longtext DEFAULT NULL,
  `PushTestMergeCommits` tinyint(1) NOT NULL,
  `ShowTestMergeCommitters` tinyint(1) NOT NULL,
  `AutoUpdatesKeepTestMerges` tinyint(1) NOT NULL,
  `AutoUpdatesSynchronize` tinyint(1) NOT NULL,
  `Id` bigint(20) NOT NULL AUTO_INCREMENT,
  `InstanceId` bigint(20) NOT NULL,
  `PostTestMergeComment` tinyint(1) NOT NULL DEFAULT 1,
  `CreateGitHubDeployments` tinyint(1) NOT NULL DEFAULT 0,
  `UpdateSubmodules` tinyint(1) NOT NULL DEFAULT 1,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `IX_RepositorySettings_InstanceId` (`InstanceId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin;

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

--
-- Table structure for table `revinfotestmerges`
--
-- Creation: Aug 01, 2024 at 12:54 PM
-- Last update: Aug 05, 2024 at 10:43 PM
--

CREATE TABLE IF NOT EXISTS `revinfotestmerges` (
  `Id` bigint(20) NOT NULL AUTO_INCREMENT,
  `TestMergeId` bigint(20) NOT NULL,
  `RevisionInformationId` bigint(20) NOT NULL,
  PRIMARY KEY (`Id`),
  KEY `IX_RevInfoTestMerges_RevisionInformationId` (`RevisionInformationId`),
  KEY `IX_RevInfoTestMerges_TestMergeId` (`TestMergeId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin;

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

--
-- Table structure for table `revisioninformations`
--
-- Creation: Aug 05, 2024 at 09:23 AM
-- Last update: Aug 05, 2024 at 10:43 PM
--

CREATE TABLE IF NOT EXISTS `revisioninformations` (
  `CommitSha` varchar(40) NOT NULL,
  `OriginCommitSha` varchar(40) NOT NULL,
  `Id` bigint(20) NOT NULL AUTO_INCREMENT,
  `InstanceId` bigint(20) NOT NULL,
  `Timestamp` datetime(6) NOT NULL DEFAULT '0001-01-01 00:00:00.000000',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `IX_RevisionInformations_InstanceId_CommitSha` (`InstanceId`,`CommitSha`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin;

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

--
-- Table structure for table `testmerges`
--
-- Creation: Aug 01, 2024 at 12:54 PM
-- Last update: Aug 05, 2024 at 10:43 PM
--

CREATE TABLE IF NOT EXISTS `testmerges` (
  `Number` int(11) NOT NULL,
  `TargetCommitSha` varchar(40) NOT NULL DEFAULT '',
  `Comment` longtext DEFAULT NULL,
  `TitleAtMerge` longtext NOT NULL,
  `BodyAtMerge` longtext NOT NULL,
  `Url` longtext NOT NULL,
  `Author` longtext NOT NULL,
  `Id` bigint(20) NOT NULL AUTO_INCREMENT,
  `MergedAt` datetime(6) NOT NULL,
  `MergedById` bigint(20) NOT NULL,
  `PrimaryRevisionInformationId` bigint(20) NOT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `IX_TestMerges_PrimaryRevisionInformationId` (`PrimaryRevisionInformationId`),
  KEY `IX_TestMerges_MergedById` (`MergedById`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin;

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

--
-- Table structure for table `users`
--
-- Creation: Aug 01, 2024 at 12:54 PM
--

CREATE TABLE IF NOT EXISTS `users` (
  `Id` bigint(20) NOT NULL AUTO_INCREMENT,
  `Enabled` tinyint(1) NOT NULL,
  `CreatedAt` datetime(6) NOT NULL,
  `SystemIdentifier` varchar(100) DEFAULT NULL,
  `Name` varchar(100) NOT NULL,
  `PasswordHash` longtext DEFAULT NULL,
  `CreatedById` bigint(20) DEFAULT NULL,
  `CanonicalName` varchar(100) NOT NULL,
  `LastPasswordUpdate` datetime(6) DEFAULT NULL,
  `GroupId` bigint(20) DEFAULT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `IX_Users_CanonicalName` (`CanonicalName`),
  UNIQUE KEY `IX_Users_SystemIdentifier` (`SystemIdentifier`),
  KEY `IX_Users_CreatedById` (`CreatedById`),
  KEY `IX_Users_GroupId` (`GroupId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin;

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

--
-- Table structure for table `__efmigrationshistory`
--
-- Creation: Aug 01, 2024 at 12:54 PM
-- Last update: Aug 05, 2024 at 02:39 AM
--

CREATE TABLE IF NOT EXISTS `__efmigrationshistory` (
  `MigrationId` varchar(150) NOT NULL,
  `ProductVersion` varchar(32) NOT NULL,
  PRIMARY KEY (`MigrationId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `chatbots`
--
ALTER TABLE `chatbots`
  ADD CONSTRAINT `FK_ChatBots_Instances_InstanceId` FOREIGN KEY (`InstanceId`) REFERENCES `instances` (`Id`) ON DELETE CASCADE;

--
-- Constraints for table `chatchannels`
--
ALTER TABLE `chatchannels`
  ADD CONSTRAINT `FK_ChatChannels_ChatBots_ChatSettingsId` FOREIGN KEY (`ChatSettingsId`) REFERENCES `chatbots` (`Id`) ON DELETE CASCADE;

--
-- Constraints for table `compilejobs`
--
ALTER TABLE `compilejobs`
  ADD CONSTRAINT `FK_CompileJobs_Jobs_JobId` FOREIGN KEY (`JobId`) REFERENCES `jobs` (`Id`) ON DELETE CASCADE,
  ADD CONSTRAINT `FK_CompileJobs_RevisionInformations_RevisionInformationId` FOREIGN KEY (`RevisionInformationId`) REFERENCES `revisioninformations` (`Id`) ON DELETE CASCADE;

--
-- Constraints for table `dreamdaemonsettings`
--
ALTER TABLE `dreamdaemonsettings`
  ADD CONSTRAINT `FK_DreamDaemonSettings_Instances_InstanceId` FOREIGN KEY (`InstanceId`) REFERENCES `instances` (`Id`) ON DELETE CASCADE;

--
-- Constraints for table `dreammakersettings`
--
ALTER TABLE `dreammakersettings`
  ADD CONSTRAINT `FK_DreamMakerSettings_Instances_InstanceId` FOREIGN KEY (`InstanceId`) REFERENCES `instances` (`Id`) ON DELETE CASCADE;

--
-- Constraints for table `instancepermissionsets`
--
ALTER TABLE `instancepermissionsets`
  ADD CONSTRAINT `FK_InstancePermissionSets_Instances_InstanceId` FOREIGN KEY (`InstanceId`) REFERENCES `instances` (`Id`) ON DELETE CASCADE,
  ADD CONSTRAINT `FK_InstancePermissionSets_PermissionSets_PermissionSetId` FOREIGN KEY (`PermissionSetId`) REFERENCES `permissionsets` (`Id`) ON DELETE CASCADE;

--
-- Constraints for table `jobs`
--
ALTER TABLE `jobs`
  ADD CONSTRAINT `FK_Jobs_Instances_InstanceId` FOREIGN KEY (`InstanceId`) REFERENCES `instances` (`Id`) ON DELETE CASCADE,
  ADD CONSTRAINT `FK_Jobs_Users_CancelledById` FOREIGN KEY (`CancelledById`) REFERENCES `users` (`Id`),
  ADD CONSTRAINT `FK_Jobs_Users_StartedById` FOREIGN KEY (`StartedById`) REFERENCES `users` (`Id`) ON DELETE CASCADE;

--
-- Constraints for table `oauthconnections`
--
ALTER TABLE `oauthconnections`
  ADD CONSTRAINT `FK_OAuthConnections_Users_UserId` FOREIGN KEY (`UserId`) REFERENCES `users` (`Id`) ON DELETE CASCADE;

--
-- Constraints for table `permissionsets`
--
ALTER TABLE `permissionsets`
  ADD CONSTRAINT `FK_PermissionSets_Groups_GroupId` FOREIGN KEY (`GroupId`) REFERENCES `groups` (`Id`) ON DELETE CASCADE,
  ADD CONSTRAINT `FK_PermissionSets_Users_UserId` FOREIGN KEY (`UserId`) REFERENCES `users` (`Id`) ON DELETE CASCADE;

--
-- Constraints for table `reattachinformations`
--
ALTER TABLE `reattachinformations`
  ADD CONSTRAINT `FK_ReattachInformations_CompileJobs_CompileJobId` FOREIGN KEY (`CompileJobId`) REFERENCES `compilejobs` (`Id`) ON DELETE CASCADE,
  ADD CONSTRAINT `FK_ReattachInformations_CompileJobs_InitialCompileJobId` FOREIGN KEY (`InitialCompileJobId`) REFERENCES `compilejobs` (`Id`);

--
-- Constraints for table `repositorysettings`
--
ALTER TABLE `repositorysettings`
  ADD CONSTRAINT `FK_RepositorySettings_Instances_InstanceId` FOREIGN KEY (`InstanceId`) REFERENCES `instances` (`Id`) ON DELETE CASCADE;

--
-- Constraints for table `revinfotestmerges`
--
ALTER TABLE `revinfotestmerges`
  ADD CONSTRAINT `FK_RevInfoTestMerges_RevisionInformations_RevisionInformationId` FOREIGN KEY (`RevisionInformationId`) REFERENCES `revisioninformations` (`Id`) ON DELETE CASCADE,
  ADD CONSTRAINT `FK_RevInfoTestMerges_TestMerges_TestMergeId` FOREIGN KEY (`TestMergeId`) REFERENCES `testmerges` (`Id`);

--
-- Constraints for table `revisioninformations`
--
ALTER TABLE `revisioninformations`
  ADD CONSTRAINT `FK_RevisionInformations_Instances_InstanceId` FOREIGN KEY (`InstanceId`) REFERENCES `instances` (`Id`) ON DELETE CASCADE;

--
-- Constraints for table `testmerges`
--
ALTER TABLE `testmerges`
  ADD CONSTRAINT `FK_TestMerges_RevisionInformations_PrimaryRevisionInformationId` FOREIGN KEY (`PrimaryRevisionInformationId`) REFERENCES `revisioninformations` (`Id`) ON DELETE CASCADE,
  ADD CONSTRAINT `FK_TestMerges_Users_MergedById` FOREIGN KEY (`MergedById`) REFERENCES `users` (`Id`);

--
-- Constraints for table `users`
--
ALTER TABLE `users`
  ADD CONSTRAINT `FK_Users_Groups_GroupId` FOREIGN KEY (`GroupId`) REFERENCES `groups` (`Id`),
  ADD CONSTRAINT `FK_Users_Users_CreatedById` FOREIGN KEY (`CreatedById`) REFERENCES `users` (`Id`);
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 */;
