CREATE TABLE IF NOT EXISTS `__EFMigrationsHistory` (
    `MigrationId` varchar(150) CHARACTER SET utf8mb4 NOT NULL,
    `ProductVersion` varchar(32) CHARACTER SET utf8mb4 NOT NULL,
    CONSTRAINT `PK___EFMigrationsHistory` PRIMARY KEY (`MigrationId`)
) CHARACTER SET=utf8mb4;

START TRANSACTION;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    ALTER DATABASE CHARACTER SET utf8mb4;

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE TABLE `Genes` (
        `Id` char(36) COLLATE ascii_general_ci NOT NULL,
        `GeneType` int NOT NULL,
        `GeneSet` longtext CHARACTER SET utf8mb4 NOT NULL,
        `Name` longtext CHARACTER SET utf8mb4 NOT NULL,
        `Architecture` longtext CHARACTER SET utf8mb4 NOT NULL,
        `LastSeen` datetime(6) NOT NULL,
        `LastSeenAgent` varchar(255) CHARACTER SET utf8mb4 NOT NULL,
        `Size` bigint NOT NULL,
        `Hash` longtext CHARACTER SET utf8mb4 NOT NULL,
        `UniqueGeneIndex` varchar(255) CHARACTER SET utf8mb4 NOT NULL,
        CONSTRAINT `PK_Genes` PRIMARY KEY (`Id`)
    ) CHARACTER SET=utf8mb4;

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE TABLE `Metadata` (
        `Id` char(36) COLLATE ascii_general_ci NOT NULL,
        `Metadata` longtext CHARACTER SET utf8mb4 NOT NULL,
        CONSTRAINT `PK_Metadata` PRIMARY KEY (`Id`)
    ) CHARACTER SET=utf8mb4;

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE TABLE `Operations` (
        `Id` char(36) COLLATE ascii_general_ci NOT NULL,
        `TenantId` char(36) COLLATE ascii_general_ci NOT NULL,
        `Status` int NOT NULL,
        `StatusMessage` longtext CHARACTER SET utf8mb4 NULL,
        `LastUpdated` datetime(6) NOT NULL,
        `ResultData` longtext CHARACTER SET utf8mb4 NULL,
        `ResultType` longtext CHARACTER SET utf8mb4 NULL,
        CONSTRAINT `PK_Operations` PRIMARY KEY (`Id`)
    ) CHARACTER SET=utf8mb4;

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE TABLE `Tenants` (
        `Id` char(36) COLLATE ascii_general_ci NOT NULL,
        CONSTRAINT `PK_Tenants` PRIMARY KEY (`Id`)
    ) CHARACTER SET=utf8mb4;

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE TABLE `MetadataGenes` (
        `MetadataId` char(36) COLLATE ascii_general_ci NOT NULL,
        `UniqueGeneIndex` varchar(255) CHARACTER SET utf8mb4 NOT NULL,
        `GeneSet` longtext CHARACTER SET utf8mb4 NOT NULL,
        `Name` longtext CHARACTER SET utf8mb4 NOT NULL,
        `Architecture` longtext CHARACTER SET utf8mb4 NOT NULL,
        CONSTRAINT `PK_MetadataGenes` PRIMARY KEY (`MetadataId`, `UniqueGeneIndex`),
        CONSTRAINT `FK_MetadataGenes_Metadata_MetadataId` FOREIGN KEY (`MetadataId`) REFERENCES `Metadata` (`Id`) ON DELETE CASCADE
    ) CHARACTER SET=utf8mb4;

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE TABLE `OperationResources` (
        `Id` char(36) COLLATE ascii_general_ci NOT NULL,
        `ResourceId` char(36) COLLATE ascii_general_ci NOT NULL,
        `ResourceType` int NOT NULL,
        `OperationId` char(36) COLLATE ascii_general_ci NOT NULL,
        CONSTRAINT `PK_OperationResources` PRIMARY KEY (`Id`),
        CONSTRAINT `FK_OperationResources_Operations_OperationId` FOREIGN KEY (`OperationId`) REFERENCES `Operations` (`Id`) ON DELETE CASCADE
    ) CHARACTER SET=utf8mb4;

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE TABLE `Projects` (
        `Id` char(36) COLLATE ascii_general_ci NOT NULL,
        `Name` longtext CHARACTER SET utf8mb4 NOT NULL,
        `BeingDeleted` tinyint(1) NOT NULL,
        `TenantId` char(36) COLLATE ascii_general_ci NOT NULL,
        CONSTRAINT `PK_Projects` PRIMARY KEY (`Id`),
        CONSTRAINT `FK_Projects_Tenants_TenantId` FOREIGN KEY (`TenantId`) REFERENCES `Tenants` (`Id`) ON DELETE RESTRICT
    ) CHARACTER SET=utf8mb4;

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE TABLE `CatletFarms` (
        `Id` char(36) COLLATE ascii_general_ci NOT NULL,
        `ProjectId` char(36) COLLATE ascii_general_ci NOT NULL,
        `ResourceType` int NOT NULL,
        `Name` longtext CHARACTER SET utf8mb4 NOT NULL,
        `Environment` longtext CHARACTER SET utf8mb4 NOT NULL,
        `HardwareId` longtext CHARACTER SET utf8mb4 NOT NULL,
        `LastInventory` datetime(6) NOT NULL,
        CONSTRAINT `PK_CatletFarms` PRIMARY KEY (`Id`),
        CONSTRAINT `FK_CatletFarms_Projects_ProjectId` FOREIGN KEY (`ProjectId`) REFERENCES `Projects` (`Id`) ON DELETE RESTRICT
    ) CHARACTER SET=utf8mb4;

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE TABLE `OperationProjectModel` (
        `Id` char(36) COLLATE ascii_general_ci NOT NULL,
        `ProjectId` char(36) COLLATE ascii_general_ci NOT NULL,
        `OperationId` char(36) COLLATE ascii_general_ci NOT NULL,
        CONSTRAINT `PK_OperationProjectModel` PRIMARY KEY (`Id`),
        CONSTRAINT `FK_OperationProjectModel_Operations_OperationId` FOREIGN KEY (`OperationId`) REFERENCES `Operations` (`Id`) ON DELETE CASCADE,
        CONSTRAINT `FK_OperationProjectModel_Projects_ProjectId` FOREIGN KEY (`ProjectId`) REFERENCES `Projects` (`Id`) ON DELETE CASCADE
    ) CHARACTER SET=utf8mb4;

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE TABLE `OperationTasks` (
        `Id` char(36) COLLATE ascii_general_ci NOT NULL,
        `ParentTaskId` char(36) COLLATE ascii_general_ci NOT NULL,
        `OperationId` char(36) COLLATE ascii_general_ci NOT NULL,
        `Status` int NOT NULL,
        `AgentName` longtext CHARACTER SET utf8mb4 NULL,
        `Name` longtext CHARACTER SET utf8mb4 NULL,
        `DisplayName` longtext CHARACTER SET utf8mb4 NULL,
        `ReferenceType` int NULL,
        `ReferenceId` longtext CHARACTER SET utf8mb4 NULL,
        `ReferenceProjectName` longtext CHARACTER SET utf8mb4 NULL,
        `LastUpdated` datetime(6) NOT NULL,
        `ProjectId` char(36) COLLATE ascii_general_ci NULL,
        CONSTRAINT `PK_OperationTasks` PRIMARY KEY (`Id`),
        CONSTRAINT `FK_OperationTasks_Operations_OperationId` FOREIGN KEY (`OperationId`) REFERENCES `Operations` (`Id`) ON DELETE CASCADE,
        CONSTRAINT `FK_OperationTasks_Projects_ProjectId` FOREIGN KEY (`ProjectId`) REFERENCES `Projects` (`Id`)
    ) CHARACTER SET=utf8mb4;

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE TABLE `ProjectRoles` (
        `Id` char(36) COLLATE ascii_general_ci NOT NULL,
        `ProjectId` char(36) COLLATE ascii_general_ci NOT NULL,
        `IdentityId` varchar(255) CHARACTER SET utf8mb4 NOT NULL,
        `RoleId` char(36) COLLATE ascii_general_ci NOT NULL,
        CONSTRAINT `PK_ProjectRoles` PRIMARY KEY (`Id`),
        CONSTRAINT `AK_ProjectRoles_ProjectId_IdentityId_RoleId` UNIQUE (`ProjectId`, `IdentityId`, `RoleId`),
        CONSTRAINT `FK_ProjectRoles_Projects_ProjectId` FOREIGN KEY (`ProjectId`) REFERENCES `Projects` (`Id`) ON DELETE CASCADE
    ) CHARACTER SET=utf8mb4;

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE TABLE `VirtualDisks` (
        `Id` char(36) COLLATE ascii_general_ci NOT NULL,
        `ProjectId` char(36) COLLATE ascii_general_ci NOT NULL,
        `ResourceType` int NOT NULL,
        `Name` longtext CHARACTER SET utf8mb4 NOT NULL,
        `Environment` longtext CHARACTER SET utf8mb4 NOT NULL,
        `StorageIdentifier` longtext CHARACTER SET utf8mb4 NULL,
        `DiskIdentifier` char(36) COLLATE ascii_general_ci NOT NULL,
        `Frozen` tinyint(1) NOT NULL,
        `Deleted` tinyint(1) NOT NULL,
        `Status` int NOT NULL,
        `Path` longtext CHARACTER SET utf8mb4 NULL,
        `FileName` longtext CHARACTER SET utf8mb4 NULL,
        `SizeBytes` bigint NULL,
        `UsedSizeBytes` bigint NULL,
        `ParentId` char(36) COLLATE ascii_general_ci NULL,
        `ParentPath` longtext CHARACTER SET utf8mb4 NULL,
        `LastSeen` datetime(6) NOT NULL,
        `LastSeenAgent` longtext CHARACTER SET utf8mb4 NULL,
        `GeneSet` longtext CHARACTER SET utf8mb4 NULL,
        `GeneName` longtext CHARACTER SET utf8mb4 NULL,
        `GeneArchitecture` longtext CHARACTER SET utf8mb4 NULL,
        `UniqueGeneIndex` varchar(255) CHARACTER SET utf8mb4 NULL,
        `DataStore` longtext CHARACTER SET utf8mb4 NOT NULL,
        `DiskType` int NOT NULL,
        CONSTRAINT `PK_VirtualDisks` PRIMARY KEY (`Id`),
        CONSTRAINT `FK_VirtualDisks_Projects_ProjectId` FOREIGN KEY (`ProjectId`) REFERENCES `Projects` (`Id`) ON DELETE RESTRICT,
        CONSTRAINT `FK_VirtualDisks_VirtualDisks_ParentId` FOREIGN KEY (`ParentId`) REFERENCES `VirtualDisks` (`Id`) ON DELETE RESTRICT
    ) CHARACTER SET=utf8mb4;

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE TABLE `VirtualNetworks` (
        `Id` char(36) COLLATE ascii_general_ci NOT NULL,
        `ProjectId` char(36) COLLATE ascii_general_ci NOT NULL,
        `ResourceType` int NOT NULL,
        `Name` longtext CHARACTER SET utf8mb4 NOT NULL,
        `Environment` longtext CHARACTER SET utf8mb4 NOT NULL,
        `NetworkProvider` longtext CHARACTER SET utf8mb4 NOT NULL,
        `IpNetwork` longtext CHARACTER SET utf8mb4 NULL,
        CONSTRAINT `PK_VirtualNetworks` PRIMARY KEY (`Id`),
        CONSTRAINT `FK_VirtualNetworks_Projects_ProjectId` FOREIGN KEY (`ProjectId`) REFERENCES `Projects` (`Id`) ON DELETE RESTRICT
    ) CHARACTER SET=utf8mb4;

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE TABLE `Catlets` (
        `Id` char(36) COLLATE ascii_general_ci NOT NULL,
        `ProjectId` char(36) COLLATE ascii_general_ci NOT NULL,
        `ResourceType` int NOT NULL,
        `Name` longtext CHARACTER SET utf8mb4 NOT NULL,
        `Environment` longtext CHARACTER SET utf8mb4 NOT NULL,
        `AgentName` longtext CHARACTER SET utf8mb4 NULL,
        `LastSeen` datetime(6) NOT NULL,
        `Status` int NOT NULL,
        `LastSeenState` datetime(6) NOT NULL,
        `CatletType` int NOT NULL,
        `UpTime` time(6) NOT NULL,
        `VMId` char(36) COLLATE ascii_general_ci NOT NULL,
        `MetadataId` char(36) COLLATE ascii_general_ci NOT NULL,
        `Path` longtext CHARACTER SET utf8mb4 NULL,
        `StorageIdentifier` longtext CHARACTER SET utf8mb4 NULL,
        `DataStore` longtext CHARACTER SET utf8mb4 NOT NULL,
        `Frozen` tinyint(1) NOT NULL,
        `HostId` char(36) COLLATE ascii_general_ci NULL,
        `CpuCount` int NOT NULL,
        `StartupMemory` bigint NOT NULL,
        `MinimumMemory` bigint NOT NULL,
        `MaximumMemory` bigint NOT NULL,
        `SecureBootTemplate` longtext CHARACTER SET utf8mb4 NULL,
        `Features` longtext CHARACTER SET utf8mb4 NOT NULL,
        CONSTRAINT `PK_Catlets` PRIMARY KEY (`Id`),
        CONSTRAINT `FK_Catlets_CatletFarms_HostId` FOREIGN KEY (`HostId`) REFERENCES `CatletFarms` (`Id`) ON DELETE RESTRICT,
        CONSTRAINT `FK_Catlets_Projects_ProjectId` FOREIGN KEY (`ProjectId`) REFERENCES `Projects` (`Id`) ON DELETE RESTRICT
    ) CHARACTER SET=utf8mb4;

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE TABLE `Logs` (
        `Id` char(36) COLLATE ascii_general_ci NOT NULL,
        `OperationId` char(36) COLLATE ascii_general_ci NOT NULL,
        `TaskId` char(36) COLLATE ascii_general_ci NOT NULL,
        `Message` longtext CHARACTER SET utf8mb4 NULL,
        `Timestamp` datetime(6) NOT NULL,
        CONSTRAINT `PK_Logs` PRIMARY KEY (`Id`),
        CONSTRAINT `FK_Logs_OperationTasks_TaskId` FOREIGN KEY (`TaskId`) REFERENCES `OperationTasks` (`Id`) ON DELETE CASCADE,
        CONSTRAINT `FK_Logs_Operations_OperationId` FOREIGN KEY (`OperationId`) REFERENCES `Operations` (`Id`) ON DELETE CASCADE
    ) CHARACTER SET=utf8mb4;

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE TABLE `TaskProgress` (
        `Id` char(36) COLLATE ascii_general_ci NOT NULL,
        `OperationId` char(36) COLLATE ascii_general_ci NOT NULL,
        `TaskId` char(36) COLLATE ascii_general_ci NOT NULL,
        `Timestamp` datetime(6) NOT NULL,
        `Progress` int NOT NULL,
        CONSTRAINT `PK_TaskProgress` PRIMARY KEY (`Id`),
        CONSTRAINT `FK_TaskProgress_OperationTasks_TaskId` FOREIGN KEY (`TaskId`) REFERENCES `OperationTasks` (`Id`) ON DELETE CASCADE
    ) CHARACTER SET=utf8mb4;

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE TABLE `NetworkPorts` (
        `Id` char(36) COLLATE ascii_general_ci NOT NULL,
        `ProviderName` longtext CHARACTER SET utf8mb4 NULL,
        `MacAddress` varchar(255) CHARACTER SET utf8mb4 NOT NULL,
        `AddressName` longtext CHARACTER SET utf8mb4 NULL,
        `Name` longtext CHARACTER SET utf8mb4 NOT NULL,
        `Discriminator` varchar(21) CHARACTER SET utf8mb4 NOT NULL,
        `SubnetName` longtext CHARACTER SET utf8mb4 NULL,
        `PoolName` longtext CHARACTER SET utf8mb4 NULL,
        `NetworkId` char(36) COLLATE ascii_general_ci NULL,
        `FloatingPortId` char(36) COLLATE ascii_general_ci NULL,
        `CatletMetadataId` char(36) COLLATE ascii_general_ci NULL,
        `RoutedNetworkId` char(36) COLLATE ascii_general_ci NULL,
        `ProviderRouterPort_SubnetName` longtext CHARACTER SET utf8mb4 NULL,
        `ProviderRouterPort_PoolName` longtext CHARACTER SET utf8mb4 NULL,
        CONSTRAINT `PK_NetworkPorts` PRIMARY KEY (`Id`),
        CONSTRAINT `FK_NetworkPorts_Metadata_CatletMetadataId` FOREIGN KEY (`CatletMetadataId`) REFERENCES `Metadata` (`Id`) ON DELETE CASCADE,
        CONSTRAINT `FK_NetworkPorts_NetworkPorts_FloatingPortId` FOREIGN KEY (`FloatingPortId`) REFERENCES `NetworkPorts` (`Id`) ON DELETE SET NULL,
        CONSTRAINT `FK_NetworkPorts_VirtualNetworks_NetworkId` FOREIGN KEY (`NetworkId`) REFERENCES `VirtualNetworks` (`Id`) ON DELETE CASCADE,
        CONSTRAINT `FK_NetworkPorts_VirtualNetworks_RoutedNetworkId` FOREIGN KEY (`RoutedNetworkId`) REFERENCES `VirtualNetworks` (`Id`) ON DELETE CASCADE
    ) CHARACTER SET=utf8mb4;

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE TABLE `Subnet` (
        `Id` char(36) COLLATE ascii_general_ci NOT NULL,
        `Name` longtext CHARACTER SET utf8mb4 NOT NULL,
        `IpNetwork` longtext CHARACTER SET utf8mb4 NULL,
        `DnsDomain` longtext CHARACTER SET utf8mb4 NULL,
        `Discriminator` varchar(21) CHARACTER SET utf8mb4 NOT NULL,
        `ProviderName` longtext CHARACTER SET utf8mb4 NULL,
        `NetworkId` char(36) COLLATE ascii_general_ci NULL,
        `DhcpLeaseTime` int NULL,
        `MTU` int NULL,
        `DnsServersV4` longtext CHARACTER SET utf8mb4 NULL,
        CONSTRAINT `PK_Subnet` PRIMARY KEY (`Id`),
        CONSTRAINT `FK_Subnet_VirtualNetworks_NetworkId` FOREIGN KEY (`NetworkId`) REFERENCES `VirtualNetworks` (`Id`) ON DELETE CASCADE
    ) CHARACTER SET=utf8mb4;

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE TABLE `CatletDrives` (
        `Id` varchar(255) CHARACTER SET utf8mb4 NOT NULL,
        `CatletId` char(36) COLLATE ascii_general_ci NOT NULL,
        `Type` int NOT NULL,
        `AttachedDiskId` char(36) COLLATE ascii_general_ci NULL,
        CONSTRAINT `PK_CatletDrives` PRIMARY KEY (`Id`),
        CONSTRAINT `FK_CatletDrives_Catlets_CatletId` FOREIGN KEY (`CatletId`) REFERENCES `Catlets` (`Id`) ON DELETE CASCADE,
        CONSTRAINT `FK_CatletDrives_VirtualDisks_AttachedDiskId` FOREIGN KEY (`AttachedDiskId`) REFERENCES `VirtualDisks` (`Id`) ON DELETE SET NULL
    ) CHARACTER SET=utf8mb4;

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE TABLE `CatletNetworkAdapters` (
        `Id` varchar(255) CHARACTER SET utf8mb4 NOT NULL,
        `CatletId` char(36) COLLATE ascii_general_ci NOT NULL,
        `Name` longtext CHARACTER SET utf8mb4 NOT NULL,
        `SwitchName` longtext CHARACTER SET utf8mb4 NULL,
        `MacAddress` longtext CHARACTER SET utf8mb4 NOT NULL,
        CONSTRAINT `PK_CatletNetworkAdapters` PRIMARY KEY (`CatletId`, `Id`),
        CONSTRAINT `FK_CatletNetworkAdapters_Catlets_CatletId` FOREIGN KEY (`CatletId`) REFERENCES `Catlets` (`Id`) ON DELETE CASCADE
    ) CHARACTER SET=utf8mb4;

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE TABLE `ReportedNetworks` (
        `Id` char(36) COLLATE ascii_general_ci NOT NULL,
        `CatletId` char(36) COLLATE ascii_general_ci NOT NULL,
        `MacAddress` longtext CHARACTER SET utf8mb4 NULL,
        `PortName` longtext CHARACTER SET utf8mb4 NULL,
        `IpV4Addresses` longtext CHARACTER SET utf8mb4 NOT NULL,
        `IpV6Addresses` longtext CHARACTER SET utf8mb4 NOT NULL,
        `IPv4DefaultGateway` longtext CHARACTER SET utf8mb4 NULL,
        `IPv6DefaultGateway` longtext CHARACTER SET utf8mb4 NULL,
        `DnsServerAddresses` longtext CHARACTER SET utf8mb4 NOT NULL,
        `IpV4Subnets` longtext CHARACTER SET utf8mb4 NOT NULL,
        `IpV6Subnets` longtext CHARACTER SET utf8mb4 NOT NULL,
        CONSTRAINT `PK_ReportedNetworks` PRIMARY KEY (`Id`),
        CONSTRAINT `FK_ReportedNetworks_Catlets_CatletId` FOREIGN KEY (`CatletId`) REFERENCES `Catlets` (`Id`) ON DELETE CASCADE
    ) CHARACTER SET=utf8mb4;

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE TABLE `IpPools` (
        `Id` char(36) COLLATE ascii_general_ci NOT NULL,
        `Name` longtext CHARACTER SET utf8mb4 NOT NULL,
        `FirstIp` longtext CHARACTER SET utf8mb4 NULL,
        `NextIp` longtext CHARACTER SET utf8mb4 NULL,
        `LastIp` longtext CHARACTER SET utf8mb4 NULL,
        `IpNetwork` longtext CHARACTER SET utf8mb4 NULL,
        `SubnetId` char(36) COLLATE ascii_general_ci NOT NULL,
        CONSTRAINT `PK_IpPools` PRIMARY KEY (`Id`),
        CONSTRAINT `FK_IpPools_Subnet_SubnetId` FOREIGN KEY (`SubnetId`) REFERENCES `Subnet` (`Id`) ON DELETE CASCADE
    ) CHARACTER SET=utf8mb4;

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE TABLE `IpAssignment` (
        `Id` char(36) COLLATE ascii_general_ci NOT NULL,
        `SubnetId` char(36) COLLATE ascii_general_ci NULL,
        `IpAddress` longtext CHARACTER SET utf8mb4 NULL,
        `NetworkPortId` char(36) COLLATE ascii_general_ci NOT NULL,
        `Discriminator` varchar(21) CHARACTER SET utf8mb4 NOT NULL,
        `PoolId` char(36) COLLATE ascii_general_ci NULL,
        `Number` int NULL,
        CONSTRAINT `PK_IpAssignment` PRIMARY KEY (`Id`),
        CONSTRAINT `FK_IpAssignment_IpPools_PoolId` FOREIGN KEY (`PoolId`) REFERENCES `IpPools` (`Id`) ON DELETE CASCADE,
        CONSTRAINT `FK_IpAssignment_NetworkPorts_NetworkPortId` FOREIGN KEY (`NetworkPortId`) REFERENCES `NetworkPorts` (`Id`) ON DELETE CASCADE,
        CONSTRAINT `FK_IpAssignment_Subnet_SubnetId` FOREIGN KEY (`SubnetId`) REFERENCES `Subnet` (`Id`) ON DELETE CASCADE
    ) CHARACTER SET=utf8mb4;

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE INDEX `IX_CatletDrives_AttachedDiskId` ON `CatletDrives` (`AttachedDiskId`);

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE INDEX `IX_CatletDrives_CatletId` ON `CatletDrives` (`CatletId`);

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE INDEX `IX_CatletFarms_ProjectId` ON `CatletFarms` (`ProjectId`);

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE INDEX `IX_Catlets_HostId` ON `Catlets` (`HostId`);

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE INDEX `IX_Catlets_ProjectId` ON `Catlets` (`ProjectId`);

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE UNIQUE INDEX `IX_Genes_UniqueGeneIndex_LastSeenAgent` ON `Genes` (`UniqueGeneIndex`, `LastSeenAgent`);

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE INDEX `IX_IpAssignment_NetworkPortId` ON `IpAssignment` (`NetworkPortId`);

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE UNIQUE INDEX `IX_IpAssignment_PoolId_Number` ON `IpAssignment` (`PoolId`, `Number`);

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE INDEX `IX_IpAssignment_SubnetId` ON `IpAssignment` (`SubnetId`);

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE INDEX `IX_IpPools_SubnetId` ON `IpPools` (`SubnetId`);

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE INDEX `IX_Logs_OperationId` ON `Logs` (`OperationId`);

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE INDEX `IX_Logs_TaskId` ON `Logs` (`TaskId`);

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE INDEX `IX_MetadataGenes_UniqueGeneIndex` ON `MetadataGenes` (`UniqueGeneIndex`);

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE INDEX `IX_NetworkPorts_CatletMetadataId` ON `NetworkPorts` (`CatletMetadataId`);

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE UNIQUE INDEX `IX_NetworkPorts_FloatingPortId` ON `NetworkPorts` (`FloatingPortId`);

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE UNIQUE INDEX `IX_NetworkPorts_MacAddress` ON `NetworkPorts` (`MacAddress`);

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE INDEX `IX_NetworkPorts_NetworkId` ON `NetworkPorts` (`NetworkId`);

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE UNIQUE INDEX `IX_NetworkPorts_RoutedNetworkId` ON `NetworkPorts` (`RoutedNetworkId`);

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE INDEX `IX_OperationProjectModel_OperationId` ON `OperationProjectModel` (`OperationId`);

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE INDEX `IX_OperationProjectModel_ProjectId` ON `OperationProjectModel` (`ProjectId`);

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE INDEX `IX_OperationResources_OperationId` ON `OperationResources` (`OperationId`);

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE INDEX `IX_OperationTasks_OperationId` ON `OperationTasks` (`OperationId`);

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE INDEX `IX_OperationTasks_ProjectId` ON `OperationTasks` (`ProjectId`);

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE INDEX `IX_Projects_TenantId` ON `Projects` (`TenantId`);

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE INDEX `IX_ReportedNetworks_CatletId` ON `ReportedNetworks` (`CatletId`);

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE INDEX `IX_Subnet_NetworkId` ON `Subnet` (`NetworkId`);

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE INDEX `IX_TaskProgress_TaskId` ON `TaskProgress` (`TaskId`);

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE INDEX `IX_VirtualDisks_ParentId` ON `VirtualDisks` (`ParentId`);

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE INDEX `IX_VirtualDisks_ProjectId` ON `VirtualDisks` (`ProjectId`);

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE INDEX `IX_VirtualDisks_UniqueGeneIndex` ON `VirtualDisks` (`UniqueGeneIndex`);

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    CREATE INDEX `IX_VirtualNetworks_ProjectId` ON `VirtualNetworks` (`ProjectId`);

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

DROP PROCEDURE IF EXISTS MigrationsScript;
DELIMITER //
CREATE PROCEDURE MigrationsScript()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20250312154633_InitialCreate') THEN

    INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`)
    VALUES ('20250312154633_InitialCreate', '8.0.11');

    END IF;
END //
DELIMITER ;
CALL MigrationsScript();
DROP PROCEDURE MigrationsScript;

COMMIT;

