diff --git a/src/modules/Elsa.Common/Extensions/EnumerableExtensions.cs b/src/modules/Elsa.Common/Extensions/EnumerableExtensions.cs index 21f621c564..f95d63992d 100644 --- a/src/modules/Elsa.Common/Extensions/EnumerableExtensions.cs +++ b/src/modules/Elsa.Common/Extensions/EnumerableExtensions.cs @@ -58,4 +58,5 @@ public static Page Paginate(this IEnumerable enumerable, PageArgs? page /// The type of the items in the lists. /// True if the lists are equal, otherwise false. public static bool IsEqualTo(this IEnumerable list1, IEnumerable list2) => list1.OrderBy(g => g).SequenceEqual(list2.OrderBy(g => g)); + } \ No newline at end of file diff --git a/src/modules/Elsa.Dapper/Modules/Management/Stores/DapperWorkflowInstanceStore.cs b/src/modules/Elsa.Dapper/Modules/Management/Stores/DapperWorkflowInstanceStore.cs index 5a59a3d05f..8f393d7d86 100644 --- a/src/modules/Elsa.Dapper/Modules/Management/Stores/DapperWorkflowInstanceStore.cs +++ b/src/modules/Elsa.Dapper/Modules/Management/Stores/DapperWorkflowInstanceStore.cs @@ -163,6 +163,7 @@ private void ApplyFilter(ParameterizedQuery query, WorkflowInstanceFilter filter .In(nameof(WorkflowInstance.DefinitionId), filter.DefinitionIds) .Is(nameof(WorkflowInstance.DefinitionVersionId), filter.DefinitionVersionId) .In(nameof(WorkflowInstance.DefinitionVersionId), filter.DefinitionVersionIds) + .In(nameof(WorkflowInstance.ParentWorkflowInstanceId), filter.ParentWorkflowInstanceIds) .Is(nameof(WorkflowInstance.Status), filter.WorkflowStatus?.ToString()) .Is(nameof(WorkflowInstance.SubStatus), filter.WorkflowSubStatus?.ToString()) .Is(nameof(WorkflowInstance.Name), filter.Version) diff --git a/src/modules/Elsa.Elasticsearch/Modules/Management/WorkflowInstanceStore.cs b/src/modules/Elsa.Elasticsearch/Modules/Management/WorkflowInstanceStore.cs index d4ed0137c6..6c4a160544 100644 --- a/src/modules/Elsa.Elasticsearch/Modules/Management/WorkflowInstanceStore.cs +++ b/src/modules/Elsa.Elasticsearch/Modules/Management/WorkflowInstanceStore.cs @@ -146,6 +146,7 @@ private static QueryDescriptor Filter(QueryDescriptor diff --git a/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Alterations/20240312145108_V3_1.cs b/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Alterations/20240326133102_V3_1.cs similarity index 100% rename from src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Alterations/20240312145108_V3_1.cs rename to src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Alterations/20240326133102_V3_1.cs diff --git a/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Alterations/v3.1.sql b/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Alterations/v3.1.sql deleted file mode 100755 index 90f43c60fe..0000000000 --- a/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Alterations/v3.1.sql +++ /dev/null @@ -1,71 +0,0 @@ -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; - -ALTER DATABASE CHARACTER SET utf8mb4; - -CREATE TABLE `AlterationJobs` ( - `Id` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `PlanId` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `WorkflowInstanceId` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `Status` int NOT NULL, - `CreatedAt` datetime(6) NOT NULL, - `StartedAt` datetime(6) NULL, - `CompletedAt` datetime(6) NULL, - `SerializedLog` longtext CHARACTER SET utf8mb4 NULL, - CONSTRAINT `PK_AlterationJobs` PRIMARY KEY (`Id`) -) CHARACTER SET=utf8mb4; - -CREATE TABLE `AlterationPlans` ( - `Id` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `Status` int NOT NULL, - `CreatedAt` datetime(6) NOT NULL, - `StartedAt` datetime(6) NULL, - `CompletedAt` datetime(6) NULL, - `SerializedAlterations` longtext CHARACTER SET utf8mb4 NULL, - `SerializedWorkflowInstanceIds` longtext CHARACTER SET utf8mb4 NULL, - CONSTRAINT `PK_AlterationPlans` PRIMARY KEY (`Id`) -) CHARACTER SET=utf8mb4; - -CREATE INDEX `IX_AlterationJob_CompletedAt` ON `AlterationJobs` (`CompletedAt`); - -CREATE INDEX `IX_AlterationJob_CreatedAt` ON `AlterationJobs` (`CreatedAt`); - -CREATE INDEX `IX_AlterationJob_PlanId` ON `AlterationJobs` (`PlanId`); - -CREATE INDEX `IX_AlterationJob_StartedAt` ON `AlterationJobs` (`StartedAt`); - -CREATE INDEX `IX_AlterationJob_Status` ON `AlterationJobs` (`Status`); - -CREATE INDEX `IX_AlterationJob_WorkflowInstanceId` ON `AlterationJobs` (`WorkflowInstanceId`); - -CREATE INDEX `IX_AlterationPlan_CompletedAt` ON `AlterationPlans` (`CompletedAt`); - -CREATE INDEX `IX_AlterationPlan_CreatedAt` ON `AlterationPlans` (`CreatedAt`); - -CREATE INDEX `IX_AlterationPlan_StartedAt` ON `AlterationPlans` (`StartedAt`); - -CREATE INDEX `IX_AlterationPlan_Status` ON `AlterationPlans` (`Status`); - -INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) -VALUES ('20231015122151_Initial', '7.0.14'); - -COMMIT; - -START TRANSACTION; - -ALTER TABLE `AlterationPlans` CHANGE `SerializedWorkflowInstanceIds` `SerializedWorkflowInstanceFilter` longtext NULL; - -ALTER TABLE `AlterationPlans` MODIFY COLUMN `Status` varchar(255) CHARACTER SET utf8mb4 NOT NULL; - -ALTER TABLE `AlterationJobs` MODIFY COLUMN `Status` varchar(255) CHARACTER SET utf8mb4 NOT NULL; - -INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) -VALUES ('20240312145108_V3_1', '7.0.14'); - -COMMIT; - diff --git a/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Identity/20240312145212_V3_1.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Identity/20240326133216_V3_1.Designer.cs similarity index 99% rename from src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Identity/20240312145212_V3_1.Designer.cs rename to src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Identity/20240326133216_V3_1.Designer.cs index 99a9c312fd..8364b3a660 100644 --- a/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Identity/20240312145212_V3_1.Designer.cs +++ b/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Identity/20240326133216_V3_1.Designer.cs @@ -10,7 +10,7 @@ namespace Elsa.EntityFrameworkCore.MySql.Migrations.Identity { [DbContext(typeof(IdentityElsaDbContext))] - [Migration("20240312145212_V3_1")] + [Migration("20240326133216_V3_1")] partial class V3_1 { /// diff --git a/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Identity/20240312145212_V3_1.cs b/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Identity/20240326133216_V3_1.cs similarity index 100% rename from src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Identity/20240312145212_V3_1.cs rename to src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Identity/20240326133216_V3_1.cs diff --git a/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Identity/v3.1.sql b/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Identity/v3.1.sql deleted file mode 100755 index 9f92600e54..0000000000 --- a/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Identity/v3.1.sql +++ /dev/null @@ -1,58 +0,0 @@ -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; - -ALTER DATABASE CHARACTER SET utf8mb4; - -CREATE TABLE `Applications` ( - `Id` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `ClientId` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `HashedClientSecret` longtext CHARACTER SET utf8mb4 NOT NULL, - `HashedClientSecretSalt` longtext CHARACTER SET utf8mb4 NOT NULL, - `Name` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `HashedApiKey` longtext CHARACTER SET utf8mb4 NOT NULL, - `HashedApiKeySalt` longtext CHARACTER SET utf8mb4 NOT NULL, - `Roles` longtext CHARACTER SET utf8mb4 NOT NULL, - CONSTRAINT `PK_Applications` PRIMARY KEY (`Id`) -) CHARACTER SET=utf8mb4; - -CREATE TABLE `Roles` ( - `Id` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `Name` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `Permissions` longtext CHARACTER SET utf8mb4 NOT NULL, - CONSTRAINT `PK_Roles` PRIMARY KEY (`Id`) -) CHARACTER SET=utf8mb4; - -CREATE TABLE `Users` ( - `Id` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `Name` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `HashedPassword` longtext CHARACTER SET utf8mb4 NOT NULL, - `HashedPasswordSalt` longtext CHARACTER SET utf8mb4 NOT NULL, - `Roles` longtext CHARACTER SET utf8mb4 NOT NULL, - CONSTRAINT `PK_Users` PRIMARY KEY (`Id`) -) CHARACTER SET=utf8mb4; - -CREATE UNIQUE INDEX `IX_Application_ClientId` ON `Applications` (`ClientId`); - -CREATE UNIQUE INDEX `IX_Application_Name` ON `Applications` (`Name`); - -CREATE UNIQUE INDEX `IX_Role_Name` ON `Roles` (`Name`); - -CREATE UNIQUE INDEX `IX_User_Name` ON `Users` (`Name`); - -INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) -VALUES ('20231015122238_Initial', '7.0.14'); - -COMMIT; - -START TRANSACTION; - -INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) -VALUES ('20240312145212_V3_1', '7.0.14'); - -COMMIT; - diff --git a/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Labels/20240312145231_V3_1.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Labels/20240326133247_V3_1.Designer.cs similarity index 98% rename from src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Labels/20240312145231_V3_1.Designer.cs rename to src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Labels/20240326133247_V3_1.Designer.cs index ff07fcebfb..1eba53ada0 100644 --- a/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Labels/20240312145231_V3_1.Designer.cs +++ b/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Labels/20240326133247_V3_1.Designer.cs @@ -10,7 +10,7 @@ namespace Elsa.EntityFrameworkCore.MySql.Migrations.Labels { [DbContext(typeof(LabelsElsaDbContext))] - [Migration("20240312145231_V3_1")] + [Migration("20240326133247_V3_1")] partial class V3_1 { /// diff --git a/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Labels/20240312145231_V3_1.cs b/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Labels/20240326133247_V3_1.cs similarity index 100% rename from src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Labels/20240312145231_V3_1.cs rename to src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Labels/20240326133247_V3_1.cs diff --git a/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/20240312145152_V3_1.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/20240326133145_V3_1.Designer.cs similarity index 97% rename from src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/20240312145152_V3_1.Designer.cs rename to src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/20240326133145_V3_1.Designer.cs index cb5f38557a..17f5e541c3 100644 --- a/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/20240312145152_V3_1.Designer.cs +++ b/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/20240326133145_V3_1.Designer.cs @@ -11,7 +11,7 @@ namespace Elsa.EntityFrameworkCore.MySql.Migrations.Management { [DbContext(typeof(ManagementElsaDbContext))] - [Migration("20240312145152_V3_1")] + [Migration("20240326133145_V3_1")] partial class V3_1 { /// @@ -145,6 +145,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Name") .HasColumnType("varchar(255)"); + b.Property("ParentWorkflowInstanceId") + .HasColumnType("longtext"); + b.Property("Status") .IsRequired() .HasColumnType("varchar(255)"); diff --git a/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/20240312145152_V3_1.cs b/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/20240326133145_V3_1.cs similarity index 84% rename from src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/20240312145152_V3_1.cs rename to src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/20240326133145_V3_1.cs index 589b130714..1f482029af 100644 --- a/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/20240312145152_V3_1.cs +++ b/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/20240326133145_V3_1.cs @@ -26,6 +26,14 @@ protected override void Up(MigrationBuilder migrationBuilder) nullable: false, defaultValue: false); + migrationBuilder.AddColumn( + name: "ParentWorkflowInstanceId", + schema: "Elsa", + table: "WorkflowInstances", + type: "longtext", + nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"); + migrationBuilder.AddColumn( name: "IsSystem", schema: "Elsa", @@ -70,6 +78,11 @@ protected override void Down(MigrationBuilder migrationBuilder) schema: "Elsa", table: "WorkflowInstances"); + migrationBuilder.DropColumn( + name: "ParentWorkflowInstanceId", + schema: "Elsa", + table: "WorkflowInstances"); + migrationBuilder.DropColumn( name: "IsSystem", schema: "Elsa", diff --git a/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs b/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs index e2ced57b39..c336127c3b 100644 --- a/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs +++ b/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs @@ -142,6 +142,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Name") .HasColumnType("varchar(255)"); + b.Property("ParentWorkflowInstanceId") + .HasColumnType("longtext"); + b.Property("Status") .IsRequired() .HasColumnType("varchar(255)"); diff --git a/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/v3.1.sql b/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/v3.1.sql deleted file mode 100755 index 103614358c..0000000000 --- a/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/v3.1.sql +++ /dev/null @@ -1,106 +0,0 @@ -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; - -ALTER DATABASE CHARACTER SET utf8mb4; - -CREATE TABLE `WorkflowDefinitions` ( - `Id` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `DefinitionId` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `Name` varchar(255) CHARACTER SET utf8mb4 NULL, - `Description` longtext CHARACTER SET utf8mb4 NULL, - `ToolVersion` longtext CHARACTER SET utf8mb4 NULL, - `ProviderName` longtext CHARACTER SET utf8mb4 NULL, - `MaterializerName` longtext CHARACTER SET utf8mb4 NOT NULL, - `MaterializerContext` longtext CHARACTER SET utf8mb4 NULL, - `StringData` longtext CHARACTER SET utf8mb4 NULL, - `BinaryData` longblob NULL, - `IsReadonly` tinyint(1) NOT NULL, - `Data` longtext CHARACTER SET utf8mb4 NULL, - `UsableAsActivity` tinyint(1) NULL, - `CreatedAt` datetime(6) NOT NULL, - `Version` int NOT NULL, - `IsLatest` tinyint(1) NOT NULL, - `IsPublished` tinyint(1) NOT NULL, - CONSTRAINT `PK_WorkflowDefinitions` PRIMARY KEY (`Id`) -) CHARACTER SET=utf8mb4; - -CREATE TABLE `WorkflowInstances` ( - `Id` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `DefinitionId` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `DefinitionVersionId` longtext CHARACTER SET utf8mb4 NOT NULL, - `Version` int NOT NULL, - `Status` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `SubStatus` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `CorrelationId` varchar(255) CHARACTER SET utf8mb4 NULL, - `Name` varchar(255) CHARACTER SET utf8mb4 NULL, - `IncidentCount` int NOT NULL, - `CreatedAt` datetime(6) NOT NULL, - `UpdatedAt` datetime(6) NOT NULL, - `FinishedAt` datetime(6) NULL, - `Data` longtext CHARACTER SET utf8mb4 NULL, - CONSTRAINT `PK_WorkflowInstances` PRIMARY KEY (`Id`) -) CHARACTER SET=utf8mb4; - -CREATE UNIQUE INDEX `IX_WorkflowDefinition_DefinitionId_Version` ON `WorkflowDefinitions` (`DefinitionId`, `Version`); - -CREATE INDEX `IX_WorkflowDefinition_IsLatest` ON `WorkflowDefinitions` (`IsLatest`); - -CREATE INDEX `IX_WorkflowDefinition_IsPublished` ON `WorkflowDefinitions` (`IsPublished`); - -CREATE INDEX `IX_WorkflowDefinition_Name` ON `WorkflowDefinitions` (`Name`); - -CREATE INDEX `IX_WorkflowDefinition_UsableAsActivity` ON `WorkflowDefinitions` (`UsableAsActivity`); - -CREATE INDEX `IX_WorkflowDefinition_Version` ON `WorkflowDefinitions` (`Version`); - -CREATE INDEX `IX_WorkflowInstance_CorrelationId` ON `WorkflowInstances` (`CorrelationId`); - -CREATE INDEX `IX_WorkflowInstance_CreatedAt` ON `WorkflowInstances` (`CreatedAt`); - -CREATE INDEX `IX_WorkflowInstance_DefinitionId` ON `WorkflowInstances` (`DefinitionId`); - -CREATE INDEX `IX_WorkflowInstance_FinishedAt` ON `WorkflowInstances` (`FinishedAt`); - -CREATE INDEX `IX_WorkflowInstance_Name` ON `WorkflowInstances` (`Name`); - -CREATE INDEX `IX_WorkflowInstance_Status` ON `WorkflowInstances` (`Status`); - -CREATE INDEX `IX_WorkflowInstance_Status_DefinitionId` ON `WorkflowInstances` (`Status`, `DefinitionId`); - -CREATE INDEX `IX_WorkflowInstance_Status_SubStatus` ON `WorkflowInstances` (`Status`, `SubStatus`); - -CREATE INDEX `IX_WorkflowInstance_Status_SubStatus_DefinitionId_Version` ON `WorkflowInstances` (`Status`, `SubStatus`, `DefinitionId`, `Version`); - -CREATE INDEX `IX_WorkflowInstance_SubStatus` ON `WorkflowInstances` (`SubStatus`); - -CREATE INDEX `IX_WorkflowInstance_SubStatus_DefinitionId` ON `WorkflowInstances` (`SubStatus`, `DefinitionId`); - -CREATE INDEX `IX_WorkflowInstance_UpdatedAt` ON `WorkflowInstances` (`UpdatedAt`); - -INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) -VALUES ('20231015122223_Initial', '7.0.14'); - -COMMIT; - -START TRANSACTION; - -ALTER TABLE `WorkflowInstances` ADD `DataCompressionAlgorithm` longtext CHARACTER SET utf8mb4 NULL; - -ALTER TABLE `WorkflowInstances` ADD `IsSystem` tinyint(1) NOT NULL DEFAULT FALSE; - -ALTER TABLE `WorkflowDefinitions` ADD `IsSystem` tinyint(1) NOT NULL DEFAULT FALSE; - -CREATE INDEX `IX_WorkflowInstance_IsSystem` ON `WorkflowInstances` (`IsSystem`); - -CREATE INDEX `IX_WorkflowDefinition_IsSystem` ON `WorkflowDefinitions` (`IsSystem`); - -INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) -VALUES ('20240312145152_V3_1', '7.0.14'); - -COMMIT; - diff --git a/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Runtime/20240312145132_V3_1.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Runtime/20240326133125_V3_1.Designer.cs similarity index 99% rename from src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Runtime/20240312145132_V3_1.Designer.cs rename to src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Runtime/20240326133125_V3_1.Designer.cs index 6f6cfaf0cd..60f3991e9f 100644 --- a/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Runtime/20240312145132_V3_1.Designer.cs +++ b/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Runtime/20240326133125_V3_1.Designer.cs @@ -11,7 +11,7 @@ namespace Elsa.EntityFrameworkCore.MySql.Migrations.Runtime { [DbContext(typeof(RuntimeElsaDbContext))] - [Migration("20240312145132_V3_1")] + [Migration("20240326133125_V3_1")] partial class V3_1 { /// diff --git a/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Runtime/20240312145132_V3_1.cs b/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Runtime/20240326133125_V3_1.cs similarity index 100% rename from src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Runtime/20240312145132_V3_1.cs rename to src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Runtime/20240326133125_V3_1.cs diff --git a/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Runtime/v3.1.sql b/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Runtime/v3.1.sql deleted file mode 100755 index 1b709ea22d..0000000000 --- a/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Runtime/v3.1.sql +++ /dev/null @@ -1,202 +0,0 @@ -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; - -ALTER DATABASE CHARACTER SET utf8mb4; - -CREATE TABLE `ActivityExecutionRecords` ( - `Id` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `WorkflowInstanceId` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `ActivityId` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `ActivityNodeId` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `ActivityType` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `ActivityTypeVersion` int NOT NULL, - `ActivityName` varchar(255) CHARACTER SET utf8mb4 NULL, - `StartedAt` datetime(6) NOT NULL, - `HasBookmarks` tinyint(1) NOT NULL, - `Status` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `CompletedAt` datetime(6) NULL, - `SerializedActivityState` longtext CHARACTER SET utf8mb4 NULL, - `SerializedException` longtext CHARACTER SET utf8mb4 NULL, - `SerializedOutputs` longtext CHARACTER SET utf8mb4 NULL, - `SerializedPayload` longtext CHARACTER SET utf8mb4 NULL, - CONSTRAINT `PK_ActivityExecutionRecords` PRIMARY KEY (`Id`) -) CHARACTER SET=utf8mb4; - -CREATE TABLE `Bookmarks` ( - `BookmarkId` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `ActivityTypeName` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `Hash` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `WorkflowInstanceId` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `ActivityInstanceId` varchar(255) CHARACTER SET utf8mb4 NULL, - `CorrelationId` longtext CHARACTER SET utf8mb4 NULL, - `CreatedAt` datetime(6) NOT NULL, - `SerializedMetadata` longtext CHARACTER SET utf8mb4 NULL, - `SerializedPayload` longtext CHARACTER SET utf8mb4 NULL, - CONSTRAINT `PK_Bookmarks` PRIMARY KEY (`BookmarkId`) -) CHARACTER SET=utf8mb4; - -CREATE TABLE `Triggers` ( - `Id` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `WorkflowDefinitionId` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `WorkflowDefinitionVersionId` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `Name` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `ActivityId` longtext CHARACTER SET utf8mb4 NOT NULL, - `Hash` varchar(255) CHARACTER SET utf8mb4 NULL, - `SerializedPayload` longtext CHARACTER SET utf8mb4 NULL, - CONSTRAINT `PK_Triggers` PRIMARY KEY (`Id`) -) CHARACTER SET=utf8mb4; - -CREATE TABLE `WorkflowExecutionLogRecords` ( - `Id` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `WorkflowDefinitionId` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `WorkflowDefinitionVersionId` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `WorkflowInstanceId` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `WorkflowVersion` int NOT NULL, - `ActivityInstanceId` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `ParentActivityInstanceId` varchar(255) CHARACTER SET utf8mb4 NULL, - `ActivityId` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `ActivityType` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `ActivityTypeVersion` int NOT NULL, - `ActivityName` varchar(255) CHARACTER SET utf8mb4 NULL, - `ActivityNodeId` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `Timestamp` datetime(6) NOT NULL, - `Sequence` bigint NOT NULL, - `EventName` varchar(255) CHARACTER SET utf8mb4 NULL, - `Message` longtext CHARACTER SET utf8mb4 NULL, - `Source` longtext CHARACTER SET utf8mb4 NULL, - `SerializedActivityState` longtext CHARACTER SET utf8mb4 NULL, - `SerializedPayload` longtext CHARACTER SET utf8mb4 NULL, - CONSTRAINT `PK_WorkflowExecutionLogRecords` PRIMARY KEY (`Id`) -) CHARACTER SET=utf8mb4; - -CREATE TABLE `WorkflowInboxMessages` ( - `Id` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `ActivityTypeName` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `Hash` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `WorkflowInstanceId` varchar(255) CHARACTER SET utf8mb4 NULL, - `CorrelationId` varchar(255) CHARACTER SET utf8mb4 NULL, - `ActivityInstanceId` varchar(255) CHARACTER SET utf8mb4 NULL, - `CreatedAt` datetime(6) NOT NULL, - `ExpiresAt` datetime(6) NOT NULL, - `SerializedBookmarkPayload` longtext CHARACTER SET utf8mb4 NULL, - `SerializedInput` longtext CHARACTER SET utf8mb4 NULL, - CONSTRAINT `PK_WorkflowInboxMessages` PRIMARY KEY (`Id`) -) CHARACTER SET=utf8mb4; - -CREATE INDEX `IX_ActivityExecutionRecord_ActivityId` ON `ActivityExecutionRecords` (`ActivityId`); - -CREATE INDEX `IX_ActivityExecutionRecord_ActivityName` ON `ActivityExecutionRecords` (`ActivityName`); - -CREATE INDEX `IX_ActivityExecutionRecord_ActivityNodeId` ON `ActivityExecutionRecords` (`ActivityNodeId`); - -CREATE INDEX `IX_ActivityExecutionRecord_ActivityType` ON `ActivityExecutionRecords` (`ActivityType`); - -CREATE INDEX `IX_ActivityExecutionRecord_ActivityType_ActivityTypeVersion` ON `ActivityExecutionRecords` (`ActivityType`, `ActivityTypeVersion`); - -CREATE INDEX `IX_ActivityExecutionRecord_ActivityTypeVersion` ON `ActivityExecutionRecords` (`ActivityTypeVersion`); - -CREATE INDEX `IX_ActivityExecutionRecord_CompletedAt` ON `ActivityExecutionRecords` (`CompletedAt`); - -CREATE INDEX `IX_ActivityExecutionRecord_HasBookmarks` ON `ActivityExecutionRecords` (`HasBookmarks`); - -CREATE INDEX `IX_ActivityExecutionRecord_StartedAt` ON `ActivityExecutionRecords` (`StartedAt`); - -CREATE INDEX `IX_ActivityExecutionRecord_Status` ON `ActivityExecutionRecords` (`Status`); - -CREATE INDEX `IX_ActivityExecutionRecord_WorkflowInstanceId` ON `ActivityExecutionRecords` (`WorkflowInstanceId`); - -CREATE INDEX `IX_StoredBookmark_ActivityInstanceId` ON `Bookmarks` (`ActivityInstanceId`); - -CREATE INDEX `IX_StoredBookmark_ActivityTypeName` ON `Bookmarks` (`ActivityTypeName`); - -CREATE INDEX `IX_StoredBookmark_ActivityTypeName_Hash` ON `Bookmarks` (`ActivityTypeName`, `Hash`); - -CREATE INDEX `IX_StoredBookmark_ActivityTypeName_Hash_WorkflowInstanceId` ON `Bookmarks` (`ActivityTypeName`, `Hash`, `WorkflowInstanceId`); - -CREATE INDEX `IX_StoredBookmark_CreatedAt` ON `Bookmarks` (`CreatedAt`); - -CREATE INDEX `IX_StoredBookmark_Hash` ON `Bookmarks` (`Hash`); - -CREATE INDEX `IX_StoredBookmark_WorkflowInstanceId` ON `Bookmarks` (`WorkflowInstanceId`); - -CREATE INDEX `IX_StoredTrigger_Hash` ON `Triggers` (`Hash`); - -CREATE INDEX `IX_StoredTrigger_Name` ON `Triggers` (`Name`); - -CREATE INDEX `IX_StoredTrigger_WorkflowDefinitionId` ON `Triggers` (`WorkflowDefinitionId`); - -CREATE INDEX `IX_StoredTrigger_WorkflowDefinitionVersionId` ON `Triggers` (`WorkflowDefinitionVersionId`); - -CREATE INDEX `IX_WorkflowExecutionLogRecord_ActivityId` ON `WorkflowExecutionLogRecords` (`ActivityId`); - -CREATE INDEX `IX_WorkflowExecutionLogRecord_ActivityInstanceId` ON `WorkflowExecutionLogRecords` (`ActivityInstanceId`); - -CREATE INDEX `IX_WorkflowExecutionLogRecord_ActivityName` ON `WorkflowExecutionLogRecords` (`ActivityName`); - -CREATE INDEX `IX_WorkflowExecutionLogRecord_ActivityNodeId` ON `WorkflowExecutionLogRecords` (`ActivityNodeId`); - -CREATE INDEX `IX_WorkflowExecutionLogRecord_ActivityType` ON `WorkflowExecutionLogRecords` (`ActivityType`); - -CREATE INDEX `IX_WorkflowExecutionLogRecord_ActivityType_ActivityTypeVersion` ON `WorkflowExecutionLogRecords` (`ActivityType`, `ActivityTypeVersion`); - -CREATE INDEX `IX_WorkflowExecutionLogRecord_ActivityTypeVersion` ON `WorkflowExecutionLogRecords` (`ActivityTypeVersion`); - -CREATE INDEX `IX_WorkflowExecutionLogRecord_EventName` ON `WorkflowExecutionLogRecords` (`EventName`); - -CREATE INDEX `IX_WorkflowExecutionLogRecord_ParentActivityInstanceId` ON `WorkflowExecutionLogRecords` (`ParentActivityInstanceId`); - -CREATE INDEX `IX_WorkflowExecutionLogRecord_Sequence` ON `WorkflowExecutionLogRecords` (`Sequence`); - -CREATE INDEX `IX_WorkflowExecutionLogRecord_Timestamp` ON `WorkflowExecutionLogRecords` (`Timestamp`); - -CREATE INDEX `IX_WorkflowExecutionLogRecord_Timestamp_Sequence` ON `WorkflowExecutionLogRecords` (`Timestamp`, `Sequence`); - -CREATE INDEX `IX_WorkflowExecutionLogRecord_WorkflowDefinitionId` ON `WorkflowExecutionLogRecords` (`WorkflowDefinitionId`); - -CREATE INDEX `IX_WorkflowExecutionLogRecord_WorkflowDefinitionVersionId` ON `WorkflowExecutionLogRecords` (`WorkflowDefinitionVersionId`); - -CREATE INDEX `IX_WorkflowExecutionLogRecord_WorkflowInstanceId` ON `WorkflowExecutionLogRecords` (`WorkflowInstanceId`); - -CREATE INDEX `IX_WorkflowExecutionLogRecord_WorkflowVersion` ON `WorkflowExecutionLogRecords` (`WorkflowVersion`); - -CREATE INDEX `IX_WorkflowInboxMessage_ActivityInstanceId` ON `WorkflowInboxMessages` (`ActivityInstanceId`); - -CREATE INDEX `IX_WorkflowInboxMessage_ActivityTypeName` ON `WorkflowInboxMessages` (`ActivityTypeName`); - -CREATE INDEX `IX_WorkflowInboxMessage_CorrelationId` ON `WorkflowInboxMessages` (`CorrelationId`); - -CREATE INDEX `IX_WorkflowInboxMessage_CreatedAt` ON `WorkflowInboxMessages` (`CreatedAt`); - -CREATE INDEX `IX_WorkflowInboxMessage_ExpiresAt` ON `WorkflowInboxMessages` (`ExpiresAt`); - -CREATE INDEX `IX_WorkflowInboxMessage_Hash` ON `WorkflowInboxMessages` (`Hash`); - -CREATE INDEX `IX_WorkflowInboxMessage_WorkflowInstanceId` ON `WorkflowInboxMessages` (`WorkflowInstanceId`); - -INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) -VALUES ('20231024160940_Initial', '7.0.14'); - -COMMIT; - -START TRANSACTION; - -ALTER TABLE `ActivityExecutionRecords` ADD `SerializedActivityStateCompressionAlgorithm` longtext CHARACTER SET utf8mb4 NULL; - -ALTER TABLE `ActivityExecutionRecords` ADD `SerializedProperties` longtext CHARACTER SET utf8mb4 NULL; - -CREATE TABLE `KeyValuePairs` ( - `Key` varchar(255) CHARACTER SET utf8mb4 NOT NULL, - `SerializedValue` longtext CHARACTER SET utf8mb4 NOT NULL, - CONSTRAINT `PK_KeyValuePairs` PRIMARY KEY (`Key`) -) CHARACTER SET=utf8mb4; - -INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) -VALUES ('20240312145132_V3_1', '7.0.14'); - -COMMIT; - diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Alterations/20240312145127_V3_1.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Alterations/20240326133121_V3_1.Designer.cs similarity index 99% rename from src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Alterations/20240312145127_V3_1.Designer.cs rename to src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Alterations/20240326133121_V3_1.Designer.cs index 317b34ec2b..deece2c164 100644 --- a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Alterations/20240312145127_V3_1.Designer.cs +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Alterations/20240326133121_V3_1.Designer.cs @@ -12,7 +12,7 @@ namespace Elsa.EntityFrameworkCore.PostgreSql.Migrations.Alterations { [DbContext(typeof(AlterationsElsaDbContext))] - [Migration("20240312145127_V3_1")] + [Migration("20240326133121_V3_1")] partial class V3_1 { /// diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Alterations/20240312145127_V3_1.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Alterations/20240326133121_V3_1.cs similarity index 100% rename from src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Alterations/20240312145127_V3_1.cs rename to src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Alterations/20240326133121_V3_1.cs diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Alterations/v3.1.sql b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Alterations/v3.1.sql deleted file mode 100755 index 20cf6570c1..0000000000 --- a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Alterations/v3.1.sql +++ /dev/null @@ -1,70 +0,0 @@ - -CREATE TABLE IF NOT EXISTS "Elsa"."__EFMigrationsHistory" ( - "MigrationId" character varying(150) NOT NULL, - "ProductVersion" character varying(32) NOT NULL, - CONSTRAINT "PK___EFMigrationsHistory" PRIMARY KEY ("MigrationId") -); - -START TRANSACTION; - -CREATE TABLE "Elsa"."AlterationJobs" ( - "Id" text NOT NULL, - "PlanId" text NOT NULL, - "WorkflowInstanceId" text NOT NULL, - "Status" integer NOT NULL, - "CreatedAt" timestamp with time zone NOT NULL, - "StartedAt" timestamp with time zone NULL, - "CompletedAt" timestamp with time zone NULL, - "SerializedLog" text NULL, - CONSTRAINT "PK_AlterationJobs" PRIMARY KEY ("Id") -); - -CREATE TABLE "Elsa"."AlterationPlans" ( - "Id" text NOT NULL, - "Status" integer NOT NULL, - "CreatedAt" timestamp with time zone NOT NULL, - "StartedAt" timestamp with time zone NULL, - "CompletedAt" timestamp with time zone NULL, - "SerializedAlterations" text NULL, - "SerializedWorkflowInstanceIds" text NULL, - CONSTRAINT "PK_AlterationPlans" PRIMARY KEY ("Id") -); - -CREATE INDEX "IX_AlterationJob_CompletedAt" ON "Elsa"."AlterationJobs" ("CompletedAt"); - -CREATE INDEX "IX_AlterationJob_CreatedAt" ON "Elsa"."AlterationJobs" ("CreatedAt"); - -CREATE INDEX "IX_AlterationJob_PlanId" ON "Elsa"."AlterationJobs" ("PlanId"); - -CREATE INDEX "IX_AlterationJob_StartedAt" ON "Elsa"."AlterationJobs" ("StartedAt"); - -CREATE INDEX "IX_AlterationJob_Status" ON "Elsa"."AlterationJobs" ("Status"); - -CREATE INDEX "IX_AlterationJob_WorkflowInstanceId" ON "Elsa"."AlterationJobs" ("WorkflowInstanceId"); - -CREATE INDEX "IX_AlterationPlan_CompletedAt" ON "Elsa"."AlterationPlans" ("CompletedAt"); - -CREATE INDEX "IX_AlterationPlan_CreatedAt" ON "Elsa"."AlterationPlans" ("CreatedAt"); - -CREATE INDEX "IX_AlterationPlan_StartedAt" ON "Elsa"."AlterationPlans" ("StartedAt"); - -CREATE INDEX "IX_AlterationPlan_Status" ON "Elsa"."AlterationPlans" ("Status"); - -INSERT INTO "Elsa"."__EFMigrationsHistory" ("MigrationId", "ProductVersion") -VALUES ('20231015122203_Initial', '7.0.14'); - -COMMIT; - -START TRANSACTION; - -ALTER TABLE "Elsa"."AlterationPlans" RENAME COLUMN "SerializedWorkflowInstanceIds" TO "SerializedWorkflowInstanceFilter"; - -ALTER TABLE "Elsa"."AlterationPlans" ALTER COLUMN "Status" TYPE text; - -ALTER TABLE "Elsa"."AlterationJobs" ALTER COLUMN "Status" TYPE text; - -INSERT INTO "Elsa"."__EFMigrationsHistory" ("MigrationId", "ProductVersion") -VALUES ('20240312145127_V3_1', '7.0.14'); - -COMMIT; - diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Identity/20240312145226_V3_1.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Identity/20240326133242_V3_1.Designer.cs similarity index 99% rename from src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Identity/20240312145226_V3_1.Designer.cs rename to src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Identity/20240326133242_V3_1.Designer.cs index 3e5d27813e..3882da36ce 100644 --- a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Identity/20240312145226_V3_1.Designer.cs +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Identity/20240326133242_V3_1.Designer.cs @@ -11,7 +11,7 @@ namespace Elsa.EntityFrameworkCore.PostgreSql.Migrations.Identity { [DbContext(typeof(IdentityElsaDbContext))] - [Migration("20240312145226_V3_1")] + [Migration("20240326133242_V3_1")] partial class V3_1 { /// diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Identity/20240312145226_V3_1.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Identity/20240326133242_V3_1.cs similarity index 100% rename from src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Identity/20240312145226_V3_1.cs rename to src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Identity/20240326133242_V3_1.cs diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Identity/v3.1.sql b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Identity/v3.1.sql deleted file mode 100755 index c604b536b6..0000000000 --- a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Identity/v3.1.sql +++ /dev/null @@ -1,59 +0,0 @@ - -CREATE TABLE IF NOT EXISTS "Elsa"."__EFMigrationsHistory" ( - "MigrationId" character varying(150) NOT NULL, - "ProductVersion" character varying(32) NOT NULL, - CONSTRAINT "PK___EFMigrationsHistory" PRIMARY KEY ("MigrationId") -); - -START TRANSACTION; - -CREATE TABLE "Elsa"."Applications" ( - "Id" text NOT NULL, - "ClientId" text NOT NULL, - "HashedClientSecret" text NOT NULL, - "HashedClientSecretSalt" text NOT NULL, - "Name" text NOT NULL, - "HashedApiKey" text NOT NULL, - "HashedApiKeySalt" text NOT NULL, - "Roles" text NOT NULL, - CONSTRAINT "PK_Applications" PRIMARY KEY ("Id") -); - -COMMIT; - -CREATE TABLE "Elsa"."Roles" ( - "Id" text NOT NULL, - "Name" text NOT NULL, - "Permissions" text NOT NULL, - CONSTRAINT "PK_Roles" PRIMARY KEY ("Id") -); - -CREATE TABLE "Elsa"."Users" ( - "Id" text NOT NULL, - "Name" text NOT NULL, - "HashedPassword" text NOT NULL, - "HashedPasswordSalt" text NOT NULL, - "Roles" text NOT NULL, - CONSTRAINT "PK_Users" PRIMARY KEY ("Id") -); - -CREATE UNIQUE INDEX "IX_Application_ClientId" ON "Elsa"."Applications" ("ClientId"); - -CREATE UNIQUE INDEX "IX_Application_Name" ON "Elsa"."Applications" ("Name"); - -CREATE UNIQUE INDEX "IX_Role_Name" ON "Elsa"."Roles" ("Name"); - -CREATE UNIQUE INDEX "IX_User_Name" ON "Elsa"."Users" ("Name"); - -INSERT INTO "Elsa"."__EFMigrationsHistory" ("MigrationId", "ProductVersion") -VALUES ('20231015122250_Initial', '7.0.14'); - -COMMIT; - -START TRANSACTION; - -INSERT INTO "Elsa"."__EFMigrationsHistory" ("MigrationId", "ProductVersion") -VALUES ('20240312145226_V3_1', '7.0.14'); - -COMMIT; - diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Labels/20240312145245_V3_1.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Labels/20240326133309_V3_1.Designer.cs similarity index 98% rename from src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Labels/20240312145245_V3_1.Designer.cs rename to src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Labels/20240326133309_V3_1.Designer.cs index 946dfdc593..aa0e4bb2ee 100644 --- a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Labels/20240312145245_V3_1.Designer.cs +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Labels/20240326133309_V3_1.Designer.cs @@ -11,7 +11,7 @@ namespace Elsa.EntityFrameworkCore.PostgreSql.Migrations.Labels { [DbContext(typeof(LabelsElsaDbContext))] - [Migration("20240312145245_V3_1")] + [Migration("20240326133309_V3_1")] partial class V3_1 { /// diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Labels/20240312145245_V3_1.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Labels/20240326133309_V3_1.cs similarity index 100% rename from src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Labels/20240312145245_V3_1.cs rename to src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Labels/20240326133309_V3_1.cs diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/20240312145207_V3_1.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/20240326133211_V3_1.Designer.cs similarity index 98% rename from src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/20240312145207_V3_1.Designer.cs rename to src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/20240326133211_V3_1.Designer.cs index 5115cd50b0..52263e776d 100644 --- a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/20240312145207_V3_1.Designer.cs +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/20240326133211_V3_1.Designer.cs @@ -12,7 +12,7 @@ namespace Elsa.EntityFrameworkCore.PostgreSql.Migrations.Management { [DbContext(typeof(ManagementElsaDbContext))] - [Migration("20240312145207_V3_1")] + [Migration("20240326133211_V3_1")] partial class V3_1 { /// @@ -148,6 +148,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Name") .HasColumnType("text"); + b.Property("ParentWorkflowInstanceId") + .HasColumnType("text"); + b.Property("Status") .IsRequired() .HasColumnType("text"); diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/20240312145207_V3_1.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/20240326133211_V3_1.cs similarity index 85% rename from src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/20240312145207_V3_1.cs rename to src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/20240326133211_V3_1.cs index fa1721e073..d0e20c7ff2 100644 --- a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/20240312145207_V3_1.cs +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/20240326133211_V3_1.cs @@ -25,6 +25,13 @@ protected override void Up(MigrationBuilder migrationBuilder) nullable: false, defaultValue: false); + migrationBuilder.AddColumn( + name: "ParentWorkflowInstanceId", + schema: "Elsa", + table: "WorkflowInstances", + type: "text", + nullable: true); + migrationBuilder.AddColumn( name: "IsSystem", schema: "Elsa", @@ -69,6 +76,11 @@ protected override void Down(MigrationBuilder migrationBuilder) schema: "Elsa", table: "WorkflowInstances"); + migrationBuilder.DropColumn( + name: "ParentWorkflowInstanceId", + schema: "Elsa", + table: "WorkflowInstances"); + migrationBuilder.DropColumn( name: "IsSystem", schema: "Elsa", diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs index 152ecb46bb..6b838b36f5 100644 --- a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs @@ -145,6 +145,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Name") .HasColumnType("text"); + b.Property("ParentWorkflowInstanceId") + .HasColumnType("text"); + b.Property("Status") .IsRequired() .HasColumnType("text"); diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/v3.1.sql b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/v3.1.sql deleted file mode 100755 index a44d13cfc6..0000000000 --- a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/v3.1.sql +++ /dev/null @@ -1,105 +0,0 @@ - -CREATE TABLE IF NOT EXISTS "Elsa"."__EFMigrationsHistory" ( - "MigrationId" character varying(150) NOT NULL, - "ProductVersion" character varying(32) NOT NULL, - CONSTRAINT "PK___EFMigrationsHistory" PRIMARY KEY ("MigrationId") -); - -START TRANSACTION; - -CREATE TABLE "Elsa"."WorkflowDefinitions" ( - "Id" text NOT NULL, - "DefinitionId" text NOT NULL, - "Name" text NULL, - "Description" text NULL, - "ToolVersion" text NULL, - "ProviderName" text NULL, - "MaterializerName" text NOT NULL, - "MaterializerContext" text NULL, - "StringData" text NULL, - "BinaryData" bytea NULL, - "IsReadonly" boolean NOT NULL, - "Data" text NULL, - "UsableAsActivity" boolean NULL, - "CreatedAt" timestamp with time zone NOT NULL, - "Version" integer NOT NULL, - "IsLatest" boolean NOT NULL, - "IsPublished" boolean NOT NULL, - CONSTRAINT "PK_WorkflowDefinitions" PRIMARY KEY ("Id") -); - -CREATE TABLE "Elsa"."WorkflowInstances" ( - "Id" text NOT NULL, - "DefinitionId" text NOT NULL, - "DefinitionVersionId" text NOT NULL, - "Version" integer NOT NULL, - "Status" text NOT NULL, - "SubStatus" text NOT NULL, - "CorrelationId" text NULL, - "Name" text NULL, - "IncidentCount" integer NOT NULL, - "CreatedAt" timestamp with time zone NOT NULL, - "UpdatedAt" timestamp with time zone NOT NULL, - "FinishedAt" timestamp with time zone NULL, - "Data" text NULL, - CONSTRAINT "PK_WorkflowInstances" PRIMARY KEY ("Id") -); - -CREATE UNIQUE INDEX "IX_WorkflowDefinition_DefinitionId_Version" ON "Elsa"."WorkflowDefinitions" ("DefinitionId", "Version"); - -CREATE INDEX "IX_WorkflowDefinition_IsLatest" ON "Elsa"."WorkflowDefinitions" ("IsLatest"); - -CREATE INDEX "IX_WorkflowDefinition_IsPublished" ON "Elsa"."WorkflowDefinitions" ("IsPublished"); - -CREATE INDEX "IX_WorkflowDefinition_Name" ON "Elsa"."WorkflowDefinitions" ("Name"); - -CREATE INDEX "IX_WorkflowDefinition_UsableAsActivity" ON "Elsa"."WorkflowDefinitions" ("UsableAsActivity"); - -CREATE INDEX "IX_WorkflowDefinition_Version" ON "Elsa"."WorkflowDefinitions" ("Version"); - -CREATE INDEX "IX_WorkflowInstance_CorrelationId" ON "Elsa"."WorkflowInstances" ("CorrelationId"); - -CREATE INDEX "IX_WorkflowInstance_CreatedAt" ON "Elsa"."WorkflowInstances" ("CreatedAt"); - -CREATE INDEX "IX_WorkflowInstance_DefinitionId" ON "Elsa"."WorkflowInstances" ("DefinitionId"); - -CREATE INDEX "IX_WorkflowInstance_FinishedAt" ON "Elsa"."WorkflowInstances" ("FinishedAt"); - -CREATE INDEX "IX_WorkflowInstance_Name" ON "Elsa"."WorkflowInstances" ("Name"); - -CREATE INDEX "IX_WorkflowInstance_Status" ON "Elsa"."WorkflowInstances" ("Status"); - -CREATE INDEX "IX_WorkflowInstance_Status_DefinitionId" ON "Elsa"."WorkflowInstances" ("Status", "DefinitionId"); - -CREATE INDEX "IX_WorkflowInstance_Status_SubStatus" ON "Elsa"."WorkflowInstances" ("Status", "SubStatus"); - -CREATE INDEX "IX_WorkflowInstance_Status_SubStatus_DefinitionId_Version" ON "Elsa"."WorkflowInstances" ("Status", "SubStatus", "DefinitionId", "Version"); - -CREATE INDEX "IX_WorkflowInstance_SubStatus" ON "Elsa"."WorkflowInstances" ("SubStatus"); - -CREATE INDEX "IX_WorkflowInstance_SubStatus_DefinitionId" ON "Elsa"."WorkflowInstances" ("SubStatus", "DefinitionId"); - -CREATE INDEX "IX_WorkflowInstance_UpdatedAt" ON "Elsa"."WorkflowInstances" ("UpdatedAt"); - -INSERT INTO "Elsa"."__EFMigrationsHistory" ("MigrationId", "ProductVersion") -VALUES ('20231015122234_Initial', '7.0.14'); - -COMMIT; - -START TRANSACTION; - -ALTER TABLE "Elsa"."WorkflowInstances" ADD "DataCompressionAlgorithm" text NULL; - -ALTER TABLE "Elsa"."WorkflowInstances" ADD "IsSystem" boolean NOT NULL DEFAULT FALSE; - -ALTER TABLE "Elsa"."WorkflowDefinitions" ADD "IsSystem" boolean NOT NULL DEFAULT FALSE; - -CREATE INDEX "IX_WorkflowInstance_IsSystem" ON "Elsa"."WorkflowInstances" ("IsSystem"); - -CREATE INDEX "IX_WorkflowDefinition_IsSystem" ON "Elsa"."WorkflowDefinitions" ("IsSystem"); - -INSERT INTO "Elsa"."__EFMigrationsHistory" ("MigrationId", "ProductVersion") -VALUES ('20240312145207_V3_1', '7.0.14'); - -COMMIT; - diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Runtime/20240312145147_V3_1.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Runtime/20240326133140_V3_1.Designer.cs similarity index 99% rename from src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Runtime/20240312145147_V3_1.Designer.cs rename to src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Runtime/20240326133140_V3_1.Designer.cs index 92e084ca32..f3b51e896b 100644 --- a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Runtime/20240312145147_V3_1.Designer.cs +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Runtime/20240326133140_V3_1.Designer.cs @@ -12,7 +12,7 @@ namespace Elsa.EntityFrameworkCore.PostgreSql.Migrations.Runtime { [DbContext(typeof(RuntimeElsaDbContext))] - [Migration("20240312145147_V3_1")] + [Migration("20240326133140_V3_1")] partial class V3_1 { /// diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Runtime/20240312145147_V3_1.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Runtime/20240326133140_V3_1.cs similarity index 100% rename from src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Runtime/20240312145147_V3_1.cs rename to src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Runtime/20240326133140_V3_1.cs diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Runtime/v3.1.sql b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Runtime/v3.1.sql deleted file mode 100755 index 9a618c3f14..0000000000 --- a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Runtime/v3.1.sql +++ /dev/null @@ -1,200 +0,0 @@ -CREATE TABLE IF NOT EXISTS "Elsa"."__EFMigrationsHistory" ( - "MigrationId" character varying(150) NOT NULL, - "ProductVersion" character varying(32) NOT NULL, - CONSTRAINT "PK___EFMigrationsHistory" PRIMARY KEY ("MigrationId") -); - -START TRANSACTION; - -CREATE TABLE "Elsa"."ActivityExecutionRecords" ( - "Id" text NOT NULL, - "WorkflowInstanceId" text NOT NULL, - "ActivityId" text NOT NULL, - "ActivityNodeId" text NOT NULL, - "ActivityType" text NOT NULL, - "ActivityTypeVersion" integer NOT NULL, - "ActivityName" text NULL, - "StartedAt" timestamp with time zone NOT NULL, - "HasBookmarks" boolean NOT NULL, - "Status" text NOT NULL, - "CompletedAt" timestamp with time zone NULL, - "SerializedActivityState" text NULL, - "SerializedException" text NULL, - "SerializedOutputs" text NULL, - "SerializedPayload" text NULL, - CONSTRAINT "PK_ActivityExecutionRecords" PRIMARY KEY ("Id") -); - -CREATE TABLE "Elsa"."Bookmarks" ( - "BookmarkId" text NOT NULL, - "ActivityTypeName" text NOT NULL, - "Hash" text NOT NULL, - "WorkflowInstanceId" text NOT NULL, - "ActivityInstanceId" text NULL, - "CorrelationId" text NULL, - "CreatedAt" timestamp with time zone NOT NULL, - "SerializedMetadata" text NULL, - "SerializedPayload" text NULL, - CONSTRAINT "PK_Bookmarks" PRIMARY KEY ("BookmarkId") -); - -CREATE TABLE "Elsa"."Triggers" ( - "Id" text NOT NULL, - "WorkflowDefinitionId" text NOT NULL, - "WorkflowDefinitionVersionId" text NOT NULL, - "Name" text NOT NULL, - "ActivityId" text NOT NULL, - "Hash" text NULL, - "SerializedPayload" text NULL, - CONSTRAINT "PK_Triggers" PRIMARY KEY ("Id") -); - -CREATE TABLE "Elsa"."WorkflowExecutionLogRecords" ( - "Id" text NOT NULL, - "WorkflowDefinitionId" text NOT NULL, - "WorkflowDefinitionVersionId" text NOT NULL, - "WorkflowInstanceId" text NOT NULL, - "WorkflowVersion" integer NOT NULL, - "ActivityInstanceId" text NOT NULL, - "ParentActivityInstanceId" text NULL, - "ActivityId" text NOT NULL, - "ActivityType" text NOT NULL, - "ActivityTypeVersion" integer NOT NULL, - "ActivityName" text NULL, - "ActivityNodeId" text NOT NULL, - "Timestamp" timestamp with time zone NOT NULL, - "Sequence" bigint NOT NULL, - "EventName" text NULL, - "Message" text NULL, - "Source" text NULL, - "SerializedActivityState" text NULL, - "SerializedPayload" text NULL, - CONSTRAINT "PK_WorkflowExecutionLogRecords" PRIMARY KEY ("Id") -); - -CREATE TABLE "Elsa"."WorkflowInboxMessages" ( - "Id" text NOT NULL, - "ActivityTypeName" text NOT NULL, - "Hash" text NOT NULL, - "WorkflowInstanceId" text NULL, - "CorrelationId" text NULL, - "ActivityInstanceId" text NULL, - "CreatedAt" timestamp with time zone NOT NULL, - "ExpiresAt" timestamp with time zone NOT NULL, - "SerializedBookmarkPayload" text NULL, - "SerializedInput" text NULL, - CONSTRAINT "PK_WorkflowInboxMessages" PRIMARY KEY ("Id") -); - -CREATE INDEX "IX_ActivityExecutionRecord_ActivityId" ON "Elsa"."ActivityExecutionRecords" ("ActivityId"); - -CREATE INDEX "IX_ActivityExecutionRecord_ActivityName" ON "Elsa"."ActivityExecutionRecords" ("ActivityName"); - -CREATE INDEX "IX_ActivityExecutionRecord_ActivityNodeId" ON "Elsa"."ActivityExecutionRecords" ("ActivityNodeId"); - -CREATE INDEX "IX_ActivityExecutionRecord_ActivityType" ON "Elsa"."ActivityExecutionRecords" ("ActivityType"); - -CREATE INDEX "IX_ActivityExecutionRecord_ActivityType_ActivityTypeVersion" ON "Elsa"."ActivityExecutionRecords" ("ActivityType", "ActivityTypeVersion"); - -CREATE INDEX "IX_ActivityExecutionRecord_ActivityTypeVersion" ON "Elsa"."ActivityExecutionRecords" ("ActivityTypeVersion"); - -CREATE INDEX "IX_ActivityExecutionRecord_CompletedAt" ON "Elsa"."ActivityExecutionRecords" ("CompletedAt"); - -CREATE INDEX "IX_ActivityExecutionRecord_HasBookmarks" ON "Elsa"."ActivityExecutionRecords" ("HasBookmarks"); - -CREATE INDEX "IX_ActivityExecutionRecord_StartedAt" ON "Elsa"."ActivityExecutionRecords" ("StartedAt"); - -CREATE INDEX "IX_ActivityExecutionRecord_Status" ON "Elsa"."ActivityExecutionRecords" ("Status"); - -CREATE INDEX "IX_ActivityExecutionRecord_WorkflowInstanceId" ON "Elsa"."ActivityExecutionRecords" ("WorkflowInstanceId"); - -CREATE INDEX "IX_StoredBookmark_ActivityInstanceId" ON "Elsa"."Bookmarks" ("ActivityInstanceId"); - -CREATE INDEX "IX_StoredBookmark_ActivityTypeName" ON "Elsa"."Bookmarks" ("ActivityTypeName"); - -CREATE INDEX "IX_StoredBookmark_ActivityTypeName_Hash" ON "Elsa"."Bookmarks" ("ActivityTypeName", "Hash"); - -CREATE INDEX "IX_StoredBookmark_ActivityTypeName_Hash_WorkflowInstanceId" ON "Elsa"."Bookmarks" ("ActivityTypeName", "Hash", "WorkflowInstanceId"); - -CREATE INDEX "IX_StoredBookmark_CreatedAt" ON "Elsa"."Bookmarks" ("CreatedAt"); - -CREATE INDEX "IX_StoredBookmark_Hash" ON "Elsa"."Bookmarks" ("Hash"); - -CREATE INDEX "IX_StoredBookmark_WorkflowInstanceId" ON "Elsa"."Bookmarks" ("WorkflowInstanceId"); - -CREATE INDEX "IX_StoredTrigger_Hash" ON "Elsa"."Triggers" ("Hash"); - -CREATE INDEX "IX_StoredTrigger_Name" ON "Elsa"."Triggers" ("Name"); - -CREATE INDEX "IX_StoredTrigger_WorkflowDefinitionId" ON "Elsa"."Triggers" ("WorkflowDefinitionId"); - -CREATE INDEX "IX_StoredTrigger_WorkflowDefinitionVersionId" ON "Elsa"."Triggers" ("WorkflowDefinitionVersionId"); - -CREATE INDEX "IX_WorkflowExecutionLogRecord_ActivityId" ON "Elsa"."WorkflowExecutionLogRecords" ("ActivityId"); - -CREATE INDEX "IX_WorkflowExecutionLogRecord_ActivityInstanceId" ON "Elsa"."WorkflowExecutionLogRecords" ("ActivityInstanceId"); - -CREATE INDEX "IX_WorkflowExecutionLogRecord_ActivityName" ON "Elsa"."WorkflowExecutionLogRecords" ("ActivityName"); - -CREATE INDEX "IX_WorkflowExecutionLogRecord_ActivityNodeId" ON "Elsa"."WorkflowExecutionLogRecords" ("ActivityNodeId"); - -CREATE INDEX "IX_WorkflowExecutionLogRecord_ActivityType" ON "Elsa"."WorkflowExecutionLogRecords" ("ActivityType"); - -CREATE INDEX "IX_WorkflowExecutionLogRecord_ActivityType_ActivityTypeVersion" ON "Elsa"."WorkflowExecutionLogRecords" ("ActivityType", "ActivityTypeVersion"); - -CREATE INDEX "IX_WorkflowExecutionLogRecord_ActivityTypeVersion" ON "Elsa"."WorkflowExecutionLogRecords" ("ActivityTypeVersion"); - -CREATE INDEX "IX_WorkflowExecutionLogRecord_EventName" ON "Elsa"."WorkflowExecutionLogRecords" ("EventName"); - -CREATE INDEX "IX_WorkflowExecutionLogRecord_ParentActivityInstanceId" ON "Elsa"."WorkflowExecutionLogRecords" ("ParentActivityInstanceId"); - -CREATE INDEX "IX_WorkflowExecutionLogRecord_Sequence" ON "Elsa"."WorkflowExecutionLogRecords" ("Sequence"); - -CREATE INDEX "IX_WorkflowExecutionLogRecord_Timestamp" ON "Elsa"."WorkflowExecutionLogRecords" ("Timestamp"); - -CREATE INDEX "IX_WorkflowExecutionLogRecord_Timestamp_Sequence" ON "Elsa"."WorkflowExecutionLogRecords" ("Timestamp", "Sequence"); - -CREATE INDEX "IX_WorkflowExecutionLogRecord_WorkflowDefinitionId" ON "Elsa"."WorkflowExecutionLogRecords" ("WorkflowDefinitionId"); - -CREATE INDEX "IX_WorkflowExecutionLogRecord_WorkflowDefinitionVersionId" ON "Elsa"."WorkflowExecutionLogRecords" ("WorkflowDefinitionVersionId"); - -CREATE INDEX "IX_WorkflowExecutionLogRecord_WorkflowInstanceId" ON "Elsa"."WorkflowExecutionLogRecords" ("WorkflowInstanceId"); - -CREATE INDEX "IX_WorkflowExecutionLogRecord_WorkflowVersion" ON "Elsa"."WorkflowExecutionLogRecords" ("WorkflowVersion"); - -CREATE INDEX "IX_WorkflowInboxMessage_ActivityInstanceId" ON "Elsa"."WorkflowInboxMessages" ("ActivityInstanceId"); - -CREATE INDEX "IX_WorkflowInboxMessage_ActivityTypeName" ON "Elsa"."WorkflowInboxMessages" ("ActivityTypeName"); - -CREATE INDEX "IX_WorkflowInboxMessage_CorrelationId" ON "Elsa"."WorkflowInboxMessages" ("CorrelationId"); - -CREATE INDEX "IX_WorkflowInboxMessage_CreatedAt" ON "Elsa"."WorkflowInboxMessages" ("CreatedAt"); - -CREATE INDEX "IX_WorkflowInboxMessage_ExpiresAt" ON "Elsa"."WorkflowInboxMessages" ("ExpiresAt"); - -CREATE INDEX "IX_WorkflowInboxMessage_Hash" ON "Elsa"."WorkflowInboxMessages" ("Hash"); - -CREATE INDEX "IX_WorkflowInboxMessage_WorkflowInstanceId" ON "Elsa"."WorkflowInboxMessages" ("WorkflowInstanceId"); - -INSERT INTO "Elsa"."__EFMigrationsHistory" ("MigrationId", "ProductVersion") -VALUES ('20231024160952_Initial', '7.0.14'); - -COMMIT; - -START TRANSACTION; - -ALTER TABLE "Elsa"."ActivityExecutionRecords" ADD "SerializedActivityStateCompressionAlgorithm" text NULL; - -ALTER TABLE "Elsa"."ActivityExecutionRecords" ADD "SerializedProperties" text NULL; - -CREATE TABLE "Elsa"."KeyValuePairs" ( - "Key" text NOT NULL, - "SerializedValue" text NOT NULL, - CONSTRAINT "PK_KeyValuePairs" PRIMARY KEY ("Key") -); - -INSERT INTO "Elsa"."__EFMigrationsHistory" ("MigrationId", "ProductVersion") -VALUES ('20240312145147_V3_1', '7.0.14'); - -COMMIT; - diff --git a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Alterations/20240312145115_V3_1.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Alterations/20240326133111_V3_1.Designer.cs similarity index 99% rename from src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Alterations/20240312145115_V3_1.Designer.cs rename to src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Alterations/20240326133111_V3_1.Designer.cs index d556df705f..c8b688f438 100644 --- a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Alterations/20240312145115_V3_1.Designer.cs +++ b/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Alterations/20240326133111_V3_1.Designer.cs @@ -12,7 +12,7 @@ namespace Elsa.EntityFrameworkCore.SqlServer.Migrations.Alterations { [DbContext(typeof(AlterationsElsaDbContext))] - [Migration("20240312145115_V3_1")] + [Migration("20240326133111_V3_1")] partial class V3_1 { /// diff --git a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Alterations/20240312145115_V3_1.cs b/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Alterations/20240326133111_V3_1.cs similarity index 100% rename from src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Alterations/20240312145115_V3_1.cs rename to src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Alterations/20240326133111_V3_1.cs diff --git a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Alterations/v3.1.sql b/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Alterations/v3.1.sql deleted file mode 100755 index 0aa241fa2c..0000000000 --- a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Alterations/v3.1.sql +++ /dev/null @@ -1,114 +0,0 @@ -IF OBJECT_ID(N'[Elsa].[__EFMigrationsHistory]') IS NULL -BEGIN - IF SCHEMA_ID(N'Elsa') IS NULL EXEC(N'CREATE SCHEMA [Elsa];'); - CREATE TABLE [Elsa].[__EFMigrationsHistory] ( - [MigrationId] nvarchar(150) NOT NULL, - [ProductVersion] nvarchar(32) NOT NULL, - CONSTRAINT [PK___EFMigrationsHistory] PRIMARY KEY ([MigrationId]) - ); -END; -GO - -BEGIN TRANSACTION; -GO - -IF SCHEMA_ID(N'Elsa') IS NULL EXEC(N'CREATE SCHEMA [Elsa];'); -GO - -CREATE TABLE [Elsa].[AlterationJobs] ( - [Id] nvarchar(450) NOT NULL, - [PlanId] nvarchar(450) NOT NULL, - [WorkflowInstanceId] nvarchar(450) NOT NULL, - [Status] int NOT NULL, - [CreatedAt] datetimeoffset NOT NULL, - [StartedAt] datetimeoffset NULL, - [CompletedAt] datetimeoffset NULL, - [SerializedLog] nvarchar(max) NULL, - CONSTRAINT [PK_AlterationJobs] PRIMARY KEY ([Id]) -); -GO - -CREATE TABLE [Elsa].[AlterationPlans] ( - [Id] nvarchar(450) NOT NULL, - [Status] int NOT NULL, - [CreatedAt] datetimeoffset NOT NULL, - [StartedAt] datetimeoffset NULL, - [CompletedAt] datetimeoffset NULL, - [SerializedAlterations] nvarchar(max) NULL, - [SerializedWorkflowInstanceIds] nvarchar(max) NULL, - CONSTRAINT [PK_AlterationPlans] PRIMARY KEY ([Id]) -); -GO - -CREATE INDEX [IX_AlterationJob_CompletedAt] ON [Elsa].[AlterationJobs] ([CompletedAt]); -GO - -CREATE INDEX [IX_AlterationJob_CreatedAt] ON [Elsa].[AlterationJobs] ([CreatedAt]); -GO - -CREATE INDEX [IX_AlterationJob_PlanId] ON [Elsa].[AlterationJobs] ([PlanId]); -GO - -CREATE INDEX [IX_AlterationJob_StartedAt] ON [Elsa].[AlterationJobs] ([StartedAt]); -GO - -CREATE INDEX [IX_AlterationJob_Status] ON [Elsa].[AlterationJobs] ([Status]); -GO - -CREATE INDEX [IX_AlterationJob_WorkflowInstanceId] ON [Elsa].[AlterationJobs] ([WorkflowInstanceId]); -GO - -CREATE INDEX [IX_AlterationPlan_CompletedAt] ON [Elsa].[AlterationPlans] ([CompletedAt]); -GO - -CREATE INDEX [IX_AlterationPlan_CreatedAt] ON [Elsa].[AlterationPlans] ([CreatedAt]); -GO - -CREATE INDEX [IX_AlterationPlan_StartedAt] ON [Elsa].[AlterationPlans] ([StartedAt]); -GO - -CREATE INDEX [IX_AlterationPlan_Status] ON [Elsa].[AlterationPlans] ([Status]); -GO - -INSERT INTO [Elsa].[__EFMigrationsHistory] ([MigrationId], [ProductVersion]) -VALUES (N'20231015122155_Initial', N'7.0.14'); -GO - -COMMIT; -GO - -BEGIN TRANSACTION; -GO - -EXEC sp_rename N'[Elsa].[AlterationPlans].[SerializedWorkflowInstanceIds]', N'SerializedWorkflowInstanceFilter', N'COLUMN'; -GO - -DROP INDEX [IX_AlterationPlan_Status] ON [Elsa].[AlterationPlans]; -DECLARE @var0 sysname; -SELECT @var0 = [d].[name] -FROM [sys].[default_constraints] [d] -INNER JOIN [sys].[columns] [c] ON [d].[parent_column_id] = [c].[column_id] AND [d].[parent_object_id] = [c].[object_id] -WHERE ([d].[parent_object_id] = OBJECT_ID(N'[Elsa].[AlterationPlans]') AND [c].[name] = N'Status'); -IF @var0 IS NOT NULL EXEC(N'ALTER TABLE [Elsa].[AlterationPlans] DROP CONSTRAINT [' + @var0 + '];'); -ALTER TABLE [Elsa].[AlterationPlans] ALTER COLUMN [Status] nvarchar(450) NOT NULL; -CREATE INDEX [IX_AlterationPlan_Status] ON [Elsa].[AlterationPlans] ([Status]); -GO - -DROP INDEX [IX_AlterationJob_Status] ON [Elsa].[AlterationJobs]; -DECLARE @var1 sysname; -SELECT @var1 = [d].[name] -FROM [sys].[default_constraints] [d] -INNER JOIN [sys].[columns] [c] ON [d].[parent_column_id] = [c].[column_id] AND [d].[parent_object_id] = [c].[object_id] -WHERE ([d].[parent_object_id] = OBJECT_ID(N'[Elsa].[AlterationJobs]') AND [c].[name] = N'Status'); -IF @var1 IS NOT NULL EXEC(N'ALTER TABLE [Elsa].[AlterationJobs] DROP CONSTRAINT [' + @var1 + '];'); -ALTER TABLE [Elsa].[AlterationJobs] ALTER COLUMN [Status] nvarchar(450) NOT NULL; -CREATE INDEX [IX_AlterationJob_Status] ON [Elsa].[AlterationJobs] ([Status]); -GO - -INSERT INTO [Elsa].[__EFMigrationsHistory] ([MigrationId], [ProductVersion]) -VALUES (N'20240312145115_V3_1', N'7.0.14'); -GO - -COMMIT; -GO - diff --git a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Identity/20240312145217_V3_1.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Identity/20240326133220_V3_1.Designer.cs similarity index 99% rename from src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Identity/20240312145217_V3_1.Designer.cs rename to src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Identity/20240326133220_V3_1.Designer.cs index 055f55fa96..eaef427a12 100644 --- a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Identity/20240312145217_V3_1.Designer.cs +++ b/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Identity/20240326133220_V3_1.Designer.cs @@ -11,7 +11,7 @@ namespace Elsa.EntityFrameworkCore.SqlServer.Migrations.Identity { [DbContext(typeof(IdentityElsaDbContext))] - [Migration("20240312145217_V3_1")] + [Migration("20240326133220_V3_1")] partial class V3_1 { /// diff --git a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Identity/20240312145217_V3_1.cs b/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Identity/20240326133220_V3_1.cs similarity index 100% rename from src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Identity/20240312145217_V3_1.cs rename to src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Identity/20240326133220_V3_1.cs diff --git a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Identity/v3.1.sql b/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Identity/v3.1.sql deleted file mode 100755 index 2f343e4bee..0000000000 --- a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Identity/v3.1.sql +++ /dev/null @@ -1,77 +0,0 @@ -IF OBJECT_ID(N'[Elsa].[__EFMigrationsHistory]') IS NULL -BEGIN - IF SCHEMA_ID(N'Elsa') IS NULL EXEC(N'CREATE SCHEMA [Elsa];'); - CREATE TABLE [Elsa].[__EFMigrationsHistory] ( - [MigrationId] nvarchar(150) NOT NULL, - [ProductVersion] nvarchar(32) NOT NULL, - CONSTRAINT [PK___EFMigrationsHistory] PRIMARY KEY ([MigrationId]) - ); -END; -GO - -BEGIN TRANSACTION; -GO - -IF SCHEMA_ID(N'Elsa') IS NULL EXEC(N'CREATE SCHEMA [Elsa];'); -GO - -CREATE TABLE [Elsa].[Applications] ( - [Id] nvarchar(450) NOT NULL, - [ClientId] nvarchar(450) NOT NULL, - [HashedClientSecret] nvarchar(max) NOT NULL, - [HashedClientSecretSalt] nvarchar(max) NOT NULL, - [Name] nvarchar(450) NOT NULL, - [HashedApiKey] nvarchar(max) NOT NULL, - [HashedApiKeySalt] nvarchar(max) NOT NULL, - [Roles] nvarchar(max) NOT NULL, - CONSTRAINT [PK_Applications] PRIMARY KEY ([Id]) -); -GO - -CREATE TABLE [Elsa].[Roles] ( - [Id] nvarchar(450) NOT NULL, - [Name] nvarchar(450) NOT NULL, - [Permissions] nvarchar(max) NOT NULL, - CONSTRAINT [PK_Roles] PRIMARY KEY ([Id]) -); -GO - -CREATE TABLE [Elsa].[Users] ( - [Id] nvarchar(450) NOT NULL, - [Name] nvarchar(450) NOT NULL, - [HashedPassword] nvarchar(max) NOT NULL, - [HashedPasswordSalt] nvarchar(max) NOT NULL, - [Roles] nvarchar(max) NOT NULL, - CONSTRAINT [PK_Users] PRIMARY KEY ([Id]) -); -GO - -CREATE UNIQUE INDEX [IX_Application_ClientId] ON [Elsa].[Applications] ([ClientId]); -GO - -CREATE UNIQUE INDEX [IX_Application_Name] ON [Elsa].[Applications] ([Name]); -GO - -CREATE UNIQUE INDEX [IX_Role_Name] ON [Elsa].[Roles] ([Name]); -GO - -CREATE UNIQUE INDEX [IX_User_Name] ON [Elsa].[Users] ([Name]); -GO - -INSERT INTO [Elsa].[__EFMigrationsHistory] ([MigrationId], [ProductVersion]) -VALUES (N'20231015122242_Initial', N'7.0.14'); -GO - -COMMIT; -GO - -BEGIN TRANSACTION; -GO - -INSERT INTO [Elsa].[__EFMigrationsHistory] ([MigrationId], [ProductVersion]) -VALUES (N'20240312145217_V3_1', N'7.0.14'); -GO - -COMMIT; -GO - diff --git a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Labels/20240312145235_V3_1.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Labels/20240326133252_V3_1.Designer.cs similarity index 98% rename from src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Labels/20240312145235_V3_1.Designer.cs rename to src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Labels/20240326133252_V3_1.Designer.cs index 40c02d8e45..b6dba197db 100644 --- a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Labels/20240312145235_V3_1.Designer.cs +++ b/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Labels/20240326133252_V3_1.Designer.cs @@ -11,7 +11,7 @@ namespace Elsa.EntityFrameworkCore.SqlServer.Migrations.Labels { [DbContext(typeof(LabelsElsaDbContext))] - [Migration("20240312145235_V3_1")] + [Migration("20240326133252_V3_1")] partial class V3_1 { /// diff --git a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Labels/20240312145235_V3_1.cs b/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Labels/20240326133252_V3_1.cs similarity index 100% rename from src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Labels/20240312145235_V3_1.cs rename to src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Labels/20240326133252_V3_1.cs diff --git a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/20240312145157_V3_1.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/20240326133156_V3_1.Designer.cs similarity index 97% rename from src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/20240312145157_V3_1.Designer.cs rename to src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/20240326133156_V3_1.Designer.cs index 13be701516..a5b73d9db3 100644 --- a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/20240312145157_V3_1.Designer.cs +++ b/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/20240326133156_V3_1.Designer.cs @@ -12,7 +12,7 @@ namespace Elsa.EntityFrameworkCore.SqlServer.Migrations.Management { [DbContext(typeof(ManagementElsaDbContext))] - [Migration("20240312145157_V3_1")] + [Migration("20240326133156_V3_1")] partial class V3_1 { /// @@ -148,6 +148,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Name") .HasColumnType("nvarchar(450)"); + b.Property("ParentWorkflowInstanceId") + .HasColumnType("nvarchar(max)"); + b.Property("Status") .IsRequired() .HasColumnType("nvarchar(450)"); diff --git a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/20240312145157_V3_1.cs b/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/20240326133156_V3_1.cs similarity index 85% rename from src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/20240312145157_V3_1.cs rename to src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/20240326133156_V3_1.cs index 83ab80d906..8146d66b49 100644 --- a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/20240312145157_V3_1.cs +++ b/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/20240326133156_V3_1.cs @@ -25,6 +25,13 @@ protected override void Up(MigrationBuilder migrationBuilder) nullable: false, defaultValue: false); + migrationBuilder.AddColumn( + name: "ParentWorkflowInstanceId", + schema: "Elsa", + table: "WorkflowInstances", + type: "nvarchar(max)", + nullable: true); + migrationBuilder.AddColumn( name: "IsSystem", schema: "Elsa", @@ -69,6 +76,11 @@ protected override void Down(MigrationBuilder migrationBuilder) schema: "Elsa", table: "WorkflowInstances"); + migrationBuilder.DropColumn( + name: "ParentWorkflowInstanceId", + schema: "Elsa", + table: "WorkflowInstances"); + migrationBuilder.DropColumn( name: "IsSystem", schema: "Elsa", diff --git a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs b/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs index 7e43d32d95..d02d91c42b 100644 --- a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs +++ b/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs @@ -145,6 +145,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Name") .HasColumnType("nvarchar(450)"); + b.Property("ParentWorkflowInstanceId") + .HasColumnType("nvarchar(max)"); + b.Property("Status") .IsRequired() .HasColumnType("nvarchar(450)"); diff --git a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/v3.1.sql b/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/v3.1.sql deleted file mode 100755 index 21d259f826..0000000000 --- a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/v3.1.sql +++ /dev/null @@ -1,143 +0,0 @@ -IF OBJECT_ID(N'[Elsa].[__EFMigrationsHistory]') IS NULL -BEGIN - IF SCHEMA_ID(N'Elsa') IS NULL EXEC(N'CREATE SCHEMA [Elsa];'); - CREATE TABLE [Elsa].[__EFMigrationsHistory] ( - [MigrationId] nvarchar(150) NOT NULL, - [ProductVersion] nvarchar(32) NOT NULL, - CONSTRAINT [PK___EFMigrationsHistory] PRIMARY KEY ([MigrationId]) - ); -END; -GO - -BEGIN TRANSACTION; -GO - -IF SCHEMA_ID(N'Elsa') IS NULL EXEC(N'CREATE SCHEMA [Elsa];'); -GO - -CREATE TABLE [Elsa].[WorkflowDefinitions] ( - [Id] nvarchar(450) NOT NULL, - [DefinitionId] nvarchar(450) NOT NULL, - [Name] nvarchar(450) NULL, - [Description] nvarchar(max) NULL, - [ToolVersion] nvarchar(max) NULL, - [ProviderName] nvarchar(max) NULL, - [MaterializerName] nvarchar(max) NOT NULL, - [MaterializerContext] nvarchar(max) NULL, - [StringData] nvarchar(max) NULL, - [BinaryData] varbinary(max) NULL, - [IsReadonly] bit NOT NULL, - [Data] nvarchar(max) NULL, - [UsableAsActivity] bit NULL, - [CreatedAt] datetimeoffset NOT NULL, - [Version] int NOT NULL, - [IsLatest] bit NOT NULL, - [IsPublished] bit NOT NULL, - CONSTRAINT [PK_WorkflowDefinitions] PRIMARY KEY ([Id]) -); -GO - -CREATE TABLE [Elsa].[WorkflowInstances] ( - [Id] nvarchar(450) NOT NULL, - [DefinitionId] nvarchar(450) NOT NULL, - [DefinitionVersionId] nvarchar(max) NOT NULL, - [Version] int NOT NULL, - [Status] nvarchar(450) NOT NULL, - [SubStatus] nvarchar(450) NOT NULL, - [CorrelationId] nvarchar(450) NULL, - [Name] nvarchar(450) NULL, - [IncidentCount] int NOT NULL, - [CreatedAt] datetimeoffset NOT NULL, - [UpdatedAt] datetimeoffset NOT NULL, - [FinishedAt] datetimeoffset NULL, - [Data] nvarchar(max) NULL, - CONSTRAINT [PK_WorkflowInstances] PRIMARY KEY ([Id]) -); -GO - -CREATE UNIQUE INDEX [IX_WorkflowDefinition_DefinitionId_Version] ON [Elsa].[WorkflowDefinitions] ([DefinitionId], [Version]); -GO - -CREATE INDEX [IX_WorkflowDefinition_IsLatest] ON [Elsa].[WorkflowDefinitions] ([IsLatest]); -GO - -CREATE INDEX [IX_WorkflowDefinition_IsPublished] ON [Elsa].[WorkflowDefinitions] ([IsPublished]); -GO - -CREATE INDEX [IX_WorkflowDefinition_Name] ON [Elsa].[WorkflowDefinitions] ([Name]); -GO - -CREATE INDEX [IX_WorkflowDefinition_UsableAsActivity] ON [Elsa].[WorkflowDefinitions] ([UsableAsActivity]); -GO - -CREATE INDEX [IX_WorkflowDefinition_Version] ON [Elsa].[WorkflowDefinitions] ([Version]); -GO - -CREATE INDEX [IX_WorkflowInstance_CorrelationId] ON [Elsa].[WorkflowInstances] ([CorrelationId]); -GO - -CREATE INDEX [IX_WorkflowInstance_CreatedAt] ON [Elsa].[WorkflowInstances] ([CreatedAt]); -GO - -CREATE INDEX [IX_WorkflowInstance_DefinitionId] ON [Elsa].[WorkflowInstances] ([DefinitionId]); -GO - -CREATE INDEX [IX_WorkflowInstance_FinishedAt] ON [Elsa].[WorkflowInstances] ([FinishedAt]); -GO - -CREATE INDEX [IX_WorkflowInstance_Name] ON [Elsa].[WorkflowInstances] ([Name]); -GO - -CREATE INDEX [IX_WorkflowInstance_Status] ON [Elsa].[WorkflowInstances] ([Status]); -GO - -CREATE INDEX [IX_WorkflowInstance_Status_DefinitionId] ON [Elsa].[WorkflowInstances] ([Status], [DefinitionId]); -GO - -CREATE INDEX [IX_WorkflowInstance_Status_SubStatus] ON [Elsa].[WorkflowInstances] ([Status], [SubStatus]); -GO - -CREATE INDEX [IX_WorkflowInstance_Status_SubStatus_DefinitionId_Version] ON [Elsa].[WorkflowInstances] ([Status], [SubStatus], [DefinitionId], [Version]); -GO - -CREATE INDEX [IX_WorkflowInstance_SubStatus] ON [Elsa].[WorkflowInstances] ([SubStatus]); -GO - -CREATE INDEX [IX_WorkflowInstance_SubStatus_DefinitionId] ON [Elsa].[WorkflowInstances] ([SubStatus], [DefinitionId]); -GO - -CREATE INDEX [IX_WorkflowInstance_UpdatedAt] ON [Elsa].[WorkflowInstances] ([UpdatedAt]); -GO - -INSERT INTO [Elsa].[__EFMigrationsHistory] ([MigrationId], [ProductVersion]) -VALUES (N'20231015122227_Initial', N'7.0.14'); -GO - -COMMIT; -GO - -BEGIN TRANSACTION; -GO - -ALTER TABLE [Elsa].[WorkflowInstances] ADD [DataCompressionAlgorithm] nvarchar(max) NULL; -GO - -ALTER TABLE [Elsa].[WorkflowInstances] ADD [IsSystem] bit NOT NULL DEFAULT CAST(0 AS bit); -GO - -ALTER TABLE [Elsa].[WorkflowDefinitions] ADD [IsSystem] bit NOT NULL DEFAULT CAST(0 AS bit); -GO - -CREATE INDEX [IX_WorkflowInstance_IsSystem] ON [Elsa].[WorkflowInstances] ([IsSystem]); -GO - -CREATE INDEX [IX_WorkflowDefinition_IsSystem] ON [Elsa].[WorkflowDefinitions] ([IsSystem]); -GO - -INSERT INTO [Elsa].[__EFMigrationsHistory] ([MigrationId], [ProductVersion]) -VALUES (N'20240312145157_V3_1', N'7.0.14'); -GO - -COMMIT; -GO - diff --git a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Runtime/20240312145137_V3_1.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Runtime/20240326133130_V3_1.Designer.cs similarity index 99% rename from src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Runtime/20240312145137_V3_1.Designer.cs rename to src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Runtime/20240326133130_V3_1.Designer.cs index 455ddd2cbb..da1f4c2e6f 100644 --- a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Runtime/20240312145137_V3_1.Designer.cs +++ b/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Runtime/20240326133130_V3_1.Designer.cs @@ -12,7 +12,7 @@ namespace Elsa.EntityFrameworkCore.SqlServer.Migrations.Runtime { [DbContext(typeof(RuntimeElsaDbContext))] - [Migration("20240312145137_V3_1")] + [Migration("20240326133130_V3_1")] partial class V3_1 { /// diff --git a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Runtime/20240312145137_V3_1.cs b/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Runtime/20240326133130_V3_1.cs similarity index 100% rename from src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Runtime/20240312145137_V3_1.cs rename to src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Runtime/20240326133130_V3_1.cs diff --git a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Runtime/v3.1.sql b/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Runtime/v3.1.sql deleted file mode 100755 index 66c022a6d1..0000000000 --- a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Runtime/v3.1.sql +++ /dev/null @@ -1,267 +0,0 @@ -IF OBJECT_ID(N'[Elsa].[__EFMigrationsHistory]') IS NULL -BEGIN - IF SCHEMA_ID(N'Elsa') IS NULL EXEC(N'CREATE SCHEMA [Elsa];'); - CREATE TABLE [Elsa].[__EFMigrationsHistory] ( - [MigrationId] nvarchar(150) NOT NULL, - [ProductVersion] nvarchar(32) NOT NULL, - CONSTRAINT [PK___EFMigrationsHistory] PRIMARY KEY ([MigrationId]) - ); -END; -GO - -BEGIN TRANSACTION; -GO - -IF SCHEMA_ID(N'Elsa') IS NULL EXEC(N'CREATE SCHEMA [Elsa];'); -GO - -CREATE TABLE [Elsa].[ActivityExecutionRecords] ( - [Id] nvarchar(450) NOT NULL, - [WorkflowInstanceId] nvarchar(450) NOT NULL, - [ActivityId] nvarchar(450) NOT NULL, - [ActivityNodeId] nvarchar(450) NOT NULL, - [ActivityType] nvarchar(450) NOT NULL, - [ActivityTypeVersion] int NOT NULL, - [ActivityName] nvarchar(450) NULL, - [StartedAt] datetimeoffset NOT NULL, - [HasBookmarks] bit NOT NULL, - [Status] nvarchar(450) NOT NULL, - [CompletedAt] datetimeoffset NULL, - [SerializedActivityState] nvarchar(max) NULL, - [SerializedException] nvarchar(max) NULL, - [SerializedOutputs] nvarchar(max) NULL, - [SerializedPayload] nvarchar(max) NULL, - CONSTRAINT [PK_ActivityExecutionRecords] PRIMARY KEY ([Id]) -); -GO - -CREATE TABLE [Elsa].[Bookmarks] ( - [BookmarkId] nvarchar(450) NOT NULL, - [ActivityTypeName] nvarchar(450) NOT NULL, - [Hash] nvarchar(450) NOT NULL, - [WorkflowInstanceId] nvarchar(450) NOT NULL, - [ActivityInstanceId] nvarchar(450) NULL, - [CorrelationId] nvarchar(max) NULL, - [CreatedAt] datetimeoffset NOT NULL, - [SerializedMetadata] nvarchar(max) NULL, - [SerializedPayload] nvarchar(max) NULL, - CONSTRAINT [PK_Bookmarks] PRIMARY KEY ([BookmarkId]) -); -GO - -CREATE TABLE [Elsa].[Triggers] ( - [Id] nvarchar(450) NOT NULL, - [WorkflowDefinitionId] nvarchar(450) NOT NULL, - [WorkflowDefinitionVersionId] nvarchar(450) NOT NULL, - [Name] nvarchar(450) NOT NULL, - [ActivityId] nvarchar(max) NOT NULL, - [Hash] nvarchar(450) NULL, - [SerializedPayload] nvarchar(max) NULL, - CONSTRAINT [PK_Triggers] PRIMARY KEY ([Id]) -); -GO - -CREATE TABLE [Elsa].[WorkflowExecutionLogRecords] ( - [Id] nvarchar(450) NOT NULL, - [WorkflowDefinitionId] nvarchar(450) NOT NULL, - [WorkflowDefinitionVersionId] nvarchar(450) NOT NULL, - [WorkflowInstanceId] nvarchar(450) NOT NULL, - [WorkflowVersion] int NOT NULL, - [ActivityInstanceId] nvarchar(450) NOT NULL, - [ParentActivityInstanceId] nvarchar(450) NULL, - [ActivityId] nvarchar(450) NOT NULL, - [ActivityType] nvarchar(450) NOT NULL, - [ActivityTypeVersion] int NOT NULL, - [ActivityName] nvarchar(450) NULL, - [ActivityNodeId] nvarchar(450) NOT NULL, - [Timestamp] datetimeoffset NOT NULL, - [Sequence] bigint NOT NULL, - [EventName] nvarchar(450) NULL, - [Message] nvarchar(max) NULL, - [Source] nvarchar(max) NULL, - [SerializedActivityState] nvarchar(max) NULL, - [SerializedPayload] nvarchar(max) NULL, - CONSTRAINT [PK_WorkflowExecutionLogRecords] PRIMARY KEY ([Id]) -); -GO - -CREATE TABLE [Elsa].[WorkflowInboxMessages] ( - [Id] nvarchar(450) NOT NULL, - [ActivityTypeName] nvarchar(450) NOT NULL, - [Hash] nvarchar(450) NOT NULL, - [WorkflowInstanceId] nvarchar(450) NULL, - [CorrelationId] nvarchar(450) NULL, - [ActivityInstanceId] nvarchar(450) NULL, - [CreatedAt] datetimeoffset NOT NULL, - [ExpiresAt] datetimeoffset NOT NULL, - [SerializedBookmarkPayload] nvarchar(max) NULL, - [SerializedInput] nvarchar(max) NULL, - CONSTRAINT [PK_WorkflowInboxMessages] PRIMARY KEY ([Id]) -); -GO - -CREATE INDEX [IX_ActivityExecutionRecord_ActivityId] ON [Elsa].[ActivityExecutionRecords] ([ActivityId]); -GO - -CREATE INDEX [IX_ActivityExecutionRecord_ActivityName] ON [Elsa].[ActivityExecutionRecords] ([ActivityName]); -GO - -CREATE INDEX [IX_ActivityExecutionRecord_ActivityNodeId] ON [Elsa].[ActivityExecutionRecords] ([ActivityNodeId]); -GO - -CREATE INDEX [IX_ActivityExecutionRecord_ActivityType] ON [Elsa].[ActivityExecutionRecords] ([ActivityType]); -GO - -CREATE INDEX [IX_ActivityExecutionRecord_ActivityType_ActivityTypeVersion] ON [Elsa].[ActivityExecutionRecords] ([ActivityType], [ActivityTypeVersion]); -GO - -CREATE INDEX [IX_ActivityExecutionRecord_ActivityTypeVersion] ON [Elsa].[ActivityExecutionRecords] ([ActivityTypeVersion]); -GO - -CREATE INDEX [IX_ActivityExecutionRecord_CompletedAt] ON [Elsa].[ActivityExecutionRecords] ([CompletedAt]); -GO - -CREATE INDEX [IX_ActivityExecutionRecord_HasBookmarks] ON [Elsa].[ActivityExecutionRecords] ([HasBookmarks]); -GO - -CREATE INDEX [IX_ActivityExecutionRecord_StartedAt] ON [Elsa].[ActivityExecutionRecords] ([StartedAt]); -GO - -CREATE INDEX [IX_ActivityExecutionRecord_Status] ON [Elsa].[ActivityExecutionRecords] ([Status]); -GO - -CREATE INDEX [IX_ActivityExecutionRecord_WorkflowInstanceId] ON [Elsa].[ActivityExecutionRecords] ([WorkflowInstanceId]); -GO - -CREATE INDEX [IX_StoredBookmark_ActivityInstanceId] ON [Elsa].[Bookmarks] ([ActivityInstanceId]); -GO - -CREATE INDEX [IX_StoredBookmark_ActivityTypeName] ON [Elsa].[Bookmarks] ([ActivityTypeName]); -GO - -CREATE INDEX [IX_StoredBookmark_ActivityTypeName_Hash] ON [Elsa].[Bookmarks] ([ActivityTypeName], [Hash]); -GO - -CREATE INDEX [IX_StoredBookmark_ActivityTypeName_Hash_WorkflowInstanceId] ON [Elsa].[Bookmarks] ([ActivityTypeName], [Hash], [WorkflowInstanceId]); -GO - -CREATE INDEX [IX_StoredBookmark_CreatedAt] ON [Elsa].[Bookmarks] ([CreatedAt]); -GO - -CREATE INDEX [IX_StoredBookmark_Hash] ON [Elsa].[Bookmarks] ([Hash]); -GO - -CREATE INDEX [IX_StoredBookmark_WorkflowInstanceId] ON [Elsa].[Bookmarks] ([WorkflowInstanceId]); -GO - -CREATE INDEX [IX_StoredTrigger_Hash] ON [Elsa].[Triggers] ([Hash]); -GO - -CREATE INDEX [IX_StoredTrigger_Name] ON [Elsa].[Triggers] ([Name]); -GO - -CREATE INDEX [IX_StoredTrigger_WorkflowDefinitionId] ON [Elsa].[Triggers] ([WorkflowDefinitionId]); -GO - -CREATE INDEX [IX_StoredTrigger_WorkflowDefinitionVersionId] ON [Elsa].[Triggers] ([WorkflowDefinitionVersionId]); -GO - -CREATE INDEX [IX_WorkflowExecutionLogRecord_ActivityId] ON [Elsa].[WorkflowExecutionLogRecords] ([ActivityId]); -GO - -CREATE INDEX [IX_WorkflowExecutionLogRecord_ActivityInstanceId] ON [Elsa].[WorkflowExecutionLogRecords] ([ActivityInstanceId]); -GO - -CREATE INDEX [IX_WorkflowExecutionLogRecord_ActivityName] ON [Elsa].[WorkflowExecutionLogRecords] ([ActivityName]); -GO - -CREATE INDEX [IX_WorkflowExecutionLogRecord_ActivityNodeId] ON [Elsa].[WorkflowExecutionLogRecords] ([ActivityNodeId]); -GO - -CREATE INDEX [IX_WorkflowExecutionLogRecord_ActivityType] ON [Elsa].[WorkflowExecutionLogRecords] ([ActivityType]); -GO - -CREATE INDEX [IX_WorkflowExecutionLogRecord_ActivityType_ActivityTypeVersion] ON [Elsa].[WorkflowExecutionLogRecords] ([ActivityType], [ActivityTypeVersion]); -GO - -CREATE INDEX [IX_WorkflowExecutionLogRecord_ActivityTypeVersion] ON [Elsa].[WorkflowExecutionLogRecords] ([ActivityTypeVersion]); -GO - -CREATE INDEX [IX_WorkflowExecutionLogRecord_EventName] ON [Elsa].[WorkflowExecutionLogRecords] ([EventName]); -GO - -CREATE INDEX [IX_WorkflowExecutionLogRecord_ParentActivityInstanceId] ON [Elsa].[WorkflowExecutionLogRecords] ([ParentActivityInstanceId]); -GO - -CREATE INDEX [IX_WorkflowExecutionLogRecord_Sequence] ON [Elsa].[WorkflowExecutionLogRecords] ([Sequence]); -GO - -CREATE INDEX [IX_WorkflowExecutionLogRecord_Timestamp] ON [Elsa].[WorkflowExecutionLogRecords] ([Timestamp]); -GO - -CREATE INDEX [IX_WorkflowExecutionLogRecord_Timestamp_Sequence] ON [Elsa].[WorkflowExecutionLogRecords] ([Timestamp], [Sequence]); -GO - -CREATE INDEX [IX_WorkflowExecutionLogRecord_WorkflowDefinitionId] ON [Elsa].[WorkflowExecutionLogRecords] ([WorkflowDefinitionId]); -GO - -CREATE INDEX [IX_WorkflowExecutionLogRecord_WorkflowDefinitionVersionId] ON [Elsa].[WorkflowExecutionLogRecords] ([WorkflowDefinitionVersionId]); -GO - -CREATE INDEX [IX_WorkflowExecutionLogRecord_WorkflowInstanceId] ON [Elsa].[WorkflowExecutionLogRecords] ([WorkflowInstanceId]); -GO - -CREATE INDEX [IX_WorkflowExecutionLogRecord_WorkflowVersion] ON [Elsa].[WorkflowExecutionLogRecords] ([WorkflowVersion]); -GO - -CREATE INDEX [IX_WorkflowInboxMessage_ActivityInstanceId] ON [Elsa].[WorkflowInboxMessages] ([ActivityInstanceId]); -GO - -CREATE INDEX [IX_WorkflowInboxMessage_ActivityTypeName] ON [Elsa].[WorkflowInboxMessages] ([ActivityTypeName]); -GO - -CREATE INDEX [IX_WorkflowInboxMessage_CorrelationId] ON [Elsa].[WorkflowInboxMessages] ([CorrelationId]); -GO - -CREATE INDEX [IX_WorkflowInboxMessage_CreatedAt] ON [Elsa].[WorkflowInboxMessages] ([CreatedAt]); -GO - -CREATE INDEX [IX_WorkflowInboxMessage_ExpiresAt] ON [Elsa].[WorkflowInboxMessages] ([ExpiresAt]); -GO - -CREATE INDEX [IX_WorkflowInboxMessage_Hash] ON [Elsa].[WorkflowInboxMessages] ([Hash]); -GO - -CREATE INDEX [IX_WorkflowInboxMessage_WorkflowInstanceId] ON [Elsa].[WorkflowInboxMessages] ([WorkflowInstanceId]); -GO - -INSERT INTO [Elsa].[__EFMigrationsHistory] ([MigrationId], [ProductVersion]) -VALUES (N'20231024160944_Initial', N'7.0.14'); -GO - -COMMIT; -GO - -BEGIN TRANSACTION; -GO - -ALTER TABLE [Elsa].[ActivityExecutionRecords] ADD [SerializedActivityStateCompressionAlgorithm] nvarchar(max) NULL; -GO - -ALTER TABLE [Elsa].[ActivityExecutionRecords] ADD [SerializedProperties] nvarchar(max) NULL; -GO - -CREATE TABLE [Elsa].[KeyValuePairs] ( - [Key] nvarchar(450) NOT NULL, - [SerializedValue] nvarchar(max) NOT NULL, - CONSTRAINT [PK_KeyValuePairs] PRIMARY KEY ([Key]) -); -GO - -INSERT INTO [Elsa].[__EFMigrationsHistory] ([MigrationId], [ProductVersion]) -VALUES (N'20240312145137_V3_1', N'7.0.14'); -GO - -COMMIT; -GO - diff --git a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Alterations/20240312145121_V3_1.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Alterations/20240326133116_V3_1.Designer.cs similarity index 99% rename from src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Alterations/20240312145121_V3_1.Designer.cs rename to src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Alterations/20240326133116_V3_1.Designer.cs index ea3fee070a..f8539bfae9 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Alterations/20240312145121_V3_1.Designer.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Alterations/20240326133116_V3_1.Designer.cs @@ -10,7 +10,7 @@ namespace Elsa.EntityFrameworkCore.Sqlite.Migrations.Alterations { [DbContext(typeof(AlterationsElsaDbContext))] - [Migration("20240312145121_V3_1")] + [Migration("20240326133116_V3_1")] partial class V3_1 { /// diff --git a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Alterations/20240312145121_V3_1.cs b/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Alterations/20240326133116_V3_1.cs similarity index 100% rename from src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Alterations/20240312145121_V3_1.cs rename to src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Alterations/20240326133116_V3_1.cs diff --git a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Alterations/v3.1.sql b/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Alterations/v3.1.sql deleted file mode 100755 index 9cc9461e36..0000000000 --- a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Alterations/v3.1.sql +++ /dev/null @@ -1,131 +0,0 @@ -CREATE TABLE IF NOT EXISTS "__EFMigrationsHistory" ( - "MigrationId" TEXT NOT NULL CONSTRAINT "PK___EFMigrationsHistory" PRIMARY KEY, - "ProductVersion" TEXT NOT NULL -); - -BEGIN TRANSACTION; - -CREATE TABLE "AlterationJobs" ( - "Id" TEXT NOT NULL CONSTRAINT "PK_AlterationJobs" PRIMARY KEY, - "PlanId" TEXT NOT NULL, - "WorkflowInstanceId" TEXT NOT NULL, - "Status" INTEGER NOT NULL, - "CreatedAt" TEXT NOT NULL, - "StartedAt" TEXT NULL, - "CompletedAt" TEXT NULL, - "SerializedLog" TEXT NULL -); - -CREATE TABLE "AlterationPlans" ( - "Id" TEXT NOT NULL CONSTRAINT "PK_AlterationPlans" PRIMARY KEY, - "Status" INTEGER NOT NULL, - "CreatedAt" TEXT NOT NULL, - "StartedAt" TEXT NULL, - "CompletedAt" TEXT NULL, - "SerializedAlterations" TEXT NULL, - "SerializedWorkflowInstanceIds" TEXT NULL -); - -CREATE INDEX "IX_AlterationJob_CompletedAt" ON "AlterationJobs" ("CompletedAt"); - -CREATE INDEX "IX_AlterationJob_CreatedAt" ON "AlterationJobs" ("CreatedAt"); - -CREATE INDEX "IX_AlterationJob_PlanId" ON "AlterationJobs" ("PlanId"); - -CREATE INDEX "IX_AlterationJob_StartedAt" ON "AlterationJobs" ("StartedAt"); - -CREATE INDEX "IX_AlterationJob_Status" ON "AlterationJobs" ("Status"); - -CREATE INDEX "IX_AlterationJob_WorkflowInstanceId" ON "AlterationJobs" ("WorkflowInstanceId"); - -CREATE INDEX "IX_AlterationPlan_CompletedAt" ON "AlterationPlans" ("CompletedAt"); - -CREATE INDEX "IX_AlterationPlan_CreatedAt" ON "AlterationPlans" ("CreatedAt"); - -CREATE INDEX "IX_AlterationPlan_StartedAt" ON "AlterationPlans" ("StartedAt"); - -CREATE INDEX "IX_AlterationPlan_Status" ON "AlterationPlans" ("Status"); - -INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion") -VALUES ('20231015122159_Initial', '7.0.14'); - -COMMIT; - -BEGIN TRANSACTION; - -ALTER TABLE "AlterationPlans" RENAME COLUMN "SerializedWorkflowInstanceIds" TO "SerializedWorkflowInstanceFilter"; - -CREATE TABLE "ef_temp_AlterationPlans" ( - "Id" TEXT NOT NULL CONSTRAINT "PK_AlterationPlans" PRIMARY KEY, - "CompletedAt" TEXT NULL, - "CreatedAt" TEXT NOT NULL, - "SerializedAlterations" TEXT NULL, - "SerializedWorkflowInstanceFilter" TEXT NULL, - "StartedAt" TEXT NULL, - "Status" TEXT NOT NULL -); - -INSERT INTO "ef_temp_AlterationPlans" ("Id", "CompletedAt", "CreatedAt", "SerializedAlterations", "SerializedWorkflowInstanceFilter", "StartedAt", "Status") -SELECT "Id", "CompletedAt", "CreatedAt", "SerializedAlterations", "SerializedWorkflowInstanceFilter", "StartedAt", "Status" -FROM "AlterationPlans"; - -CREATE TABLE "ef_temp_AlterationJobs" ( - "Id" TEXT NOT NULL CONSTRAINT "PK_AlterationJobs" PRIMARY KEY, - "CompletedAt" TEXT NULL, - "CreatedAt" TEXT NOT NULL, - "PlanId" TEXT NOT NULL, - "SerializedLog" TEXT NULL, - "StartedAt" TEXT NULL, - "Status" TEXT NOT NULL, - "WorkflowInstanceId" TEXT NOT NULL -); - -INSERT INTO "ef_temp_AlterationJobs" ("Id", "CompletedAt", "CreatedAt", "PlanId", "SerializedLog", "StartedAt", "Status", "WorkflowInstanceId") -SELECT "Id", "CompletedAt", "CreatedAt", "PlanId", "SerializedLog", "StartedAt", "Status", "WorkflowInstanceId" -FROM "AlterationJobs"; - -COMMIT; - -PRAGMA foreign_keys = 0; - -BEGIN TRANSACTION; - -DROP TABLE "AlterationPlans"; - -ALTER TABLE "ef_temp_AlterationPlans" RENAME TO "AlterationPlans"; - -DROP TABLE "AlterationJobs"; - -ALTER TABLE "ef_temp_AlterationJobs" RENAME TO "AlterationJobs"; - -COMMIT; - -PRAGMA foreign_keys = 1; - -BEGIN TRANSACTION; - -CREATE INDEX "IX_AlterationPlan_CompletedAt" ON "AlterationPlans" ("CompletedAt"); - -CREATE INDEX "IX_AlterationPlan_CreatedAt" ON "AlterationPlans" ("CreatedAt"); - -CREATE INDEX "IX_AlterationPlan_StartedAt" ON "AlterationPlans" ("StartedAt"); - -CREATE INDEX "IX_AlterationPlan_Status" ON "AlterationPlans" ("Status"); - -CREATE INDEX "IX_AlterationJob_CompletedAt" ON "AlterationJobs" ("CompletedAt"); - -CREATE INDEX "IX_AlterationJob_CreatedAt" ON "AlterationJobs" ("CreatedAt"); - -CREATE INDEX "IX_AlterationJob_PlanId" ON "AlterationJobs" ("PlanId"); - -CREATE INDEX "IX_AlterationJob_StartedAt" ON "AlterationJobs" ("StartedAt"); - -CREATE INDEX "IX_AlterationJob_Status" ON "AlterationJobs" ("Status"); - -CREATE INDEX "IX_AlterationJob_WorkflowInstanceId" ON "AlterationJobs" ("WorkflowInstanceId"); - -INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion") -VALUES ('20240312145121_V3_1', '7.0.14'); - -COMMIT; - diff --git a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Identity/20240312145221_V3_1.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Identity/20240326133236_V3_1.Designer.cs similarity index 99% rename from src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Identity/20240312145221_V3_1.Designer.cs rename to src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Identity/20240326133236_V3_1.Designer.cs index 4485ca6d90..ab6482f4cb 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Identity/20240312145221_V3_1.Designer.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Identity/20240326133236_V3_1.Designer.cs @@ -10,7 +10,7 @@ namespace Elsa.EntityFrameworkCore.Sqlite.Migrations.Identity { [DbContext(typeof(IdentityElsaDbContext))] - [Migration("20240312145221_V3_1")] + [Migration("20240326133236_V3_1")] partial class V3_1 { /// diff --git a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Identity/20240312145221_V3_1.cs b/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Identity/20240326133236_V3_1.cs similarity index 100% rename from src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Identity/20240312145221_V3_1.cs rename to src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Identity/20240326133236_V3_1.cs diff --git a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Identity/v3.1.sql b/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Identity/v3.1.sql deleted file mode 100755 index c6118c85fc..0000000000 --- a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Identity/v3.1.sql +++ /dev/null @@ -1,52 +0,0 @@ -CREATE TABLE IF NOT EXISTS "__EFMigrationsHistory" ( - "MigrationId" TEXT NOT NULL CONSTRAINT "PK___EFMigrationsHistory" PRIMARY KEY, - "ProductVersion" TEXT NOT NULL -); - -BEGIN TRANSACTION; - -CREATE TABLE "Applications" ( - "Id" TEXT NOT NULL CONSTRAINT "PK_Applications" PRIMARY KEY, - "ClientId" TEXT NOT NULL, - "HashedClientSecret" TEXT NOT NULL, - "HashedClientSecretSalt" TEXT NOT NULL, - "Name" TEXT NOT NULL, - "HashedApiKey" TEXT NOT NULL, - "HashedApiKeySalt" TEXT NOT NULL, - "Roles" TEXT NOT NULL -); - -CREATE TABLE "Roles" ( - "Id" TEXT NOT NULL CONSTRAINT "PK_Roles" PRIMARY KEY, - "Name" TEXT NOT NULL, - "Permissions" TEXT NOT NULL -); - -CREATE TABLE "Users" ( - "Id" TEXT NOT NULL CONSTRAINT "PK_Users" PRIMARY KEY, - "Name" TEXT NOT NULL, - "HashedPassword" TEXT NOT NULL, - "HashedPasswordSalt" TEXT NOT NULL, - "Roles" TEXT NOT NULL -); - -CREATE UNIQUE INDEX "IX_Application_ClientId" ON "Applications" ("ClientId"); - -CREATE UNIQUE INDEX "IX_Application_Name" ON "Applications" ("Name"); - -CREATE UNIQUE INDEX "IX_Role_Name" ON "Roles" ("Name"); - -CREATE UNIQUE INDEX "IX_User_Name" ON "Users" ("Name"); - -INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion") -VALUES ('20231015122246_Initial', '7.0.14'); - -COMMIT; - -BEGIN TRANSACTION; - -INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion") -VALUES ('20240312145221_V3_1', '7.0.14'); - -COMMIT; - diff --git a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Labels/20240312145240_V3_1.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Labels/20240326133257_V3_1.Designer.cs similarity index 98% rename from src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Labels/20240312145240_V3_1.Designer.cs rename to src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Labels/20240326133257_V3_1.Designer.cs index 60788ccde5..2d8b1df787 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Labels/20240312145240_V3_1.Designer.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Labels/20240326133257_V3_1.Designer.cs @@ -10,7 +10,7 @@ namespace Elsa.EntityFrameworkCore.Sqlite.Migrations.Labels { [DbContext(typeof(LabelsElsaDbContext))] - [Migration("20240312145240_V3_1")] + [Migration("20240326133257_V3_1")] partial class V3_1 { /// diff --git a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Labels/20240312145240_V3_1.cs b/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Labels/20240326133257_V3_1.cs similarity index 100% rename from src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Labels/20240312145240_V3_1.cs rename to src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Labels/20240326133257_V3_1.cs diff --git a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/20240312145202_V3_1.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/20240326133207_V3_1.Designer.cs similarity index 97% rename from src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/20240312145202_V3_1.Designer.cs rename to src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/20240326133207_V3_1.Designer.cs index e306a92b10..951e24b63e 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/20240312145202_V3_1.Designer.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/20240326133207_V3_1.Designer.cs @@ -11,7 +11,7 @@ namespace Elsa.EntityFrameworkCore.Sqlite.Migrations.Management { [DbContext(typeof(ManagementElsaDbContext))] - [Migration("20240312145202_V3_1")] + [Migration("20240326133207_V3_1")] partial class V3_1 { /// @@ -144,6 +144,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Name") .HasColumnType("TEXT"); + b.Property("ParentWorkflowInstanceId") + .HasColumnType("TEXT"); + b.Property("Status") .IsRequired() .HasColumnType("TEXT"); diff --git a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/20240312145202_V3_1.cs b/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/20240326133207_V3_1.cs similarity index 86% rename from src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/20240312145202_V3_1.cs rename to src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/20240326133207_V3_1.cs index bbae7d9e63..6a834f582c 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/20240312145202_V3_1.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/20240326133207_V3_1.cs @@ -23,6 +23,12 @@ protected override void Up(MigrationBuilder migrationBuilder) nullable: false, defaultValue: false); + migrationBuilder.AddColumn( + name: "ParentWorkflowInstanceId", + table: "WorkflowInstances", + type: "TEXT", + nullable: true); + migrationBuilder.AddColumn( name: "IsSystem", table: "WorkflowDefinitions", @@ -60,6 +66,10 @@ protected override void Down(MigrationBuilder migrationBuilder) name: "IsSystem", table: "WorkflowInstances"); + migrationBuilder.DropColumn( + name: "ParentWorkflowInstanceId", + table: "WorkflowInstances"); + migrationBuilder.DropColumn( name: "IsSystem", table: "WorkflowDefinitions"); diff --git a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs b/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs index 6883d8b76f..0e942456ca 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs @@ -141,6 +141,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Name") .HasColumnType("TEXT"); + b.Property("ParentWorkflowInstanceId") + .HasColumnType("TEXT"); + b.Property("Status") .IsRequired() .HasColumnType("TEXT"); diff --git a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/v3.1.sql b/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/v3.1.sql deleted file mode 100755 index b12055d5c2..0000000000 --- a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/v3.1.sql +++ /dev/null @@ -1,101 +0,0 @@ -CREATE TABLE IF NOT EXISTS "__EFMigrationsHistory" ( - "MigrationId" TEXT NOT NULL CONSTRAINT "PK___EFMigrationsHistory" PRIMARY KEY, - "ProductVersion" TEXT NOT NULL -); - -BEGIN TRANSACTION; - -CREATE TABLE "WorkflowDefinitions" ( - "Id" TEXT NOT NULL CONSTRAINT "PK_WorkflowDefinitions" PRIMARY KEY, - "DefinitionId" TEXT NOT NULL, - "Name" TEXT NULL, - "Description" TEXT NULL, - "ToolVersion" TEXT NULL, - "ProviderName" TEXT NULL, - "MaterializerName" TEXT NOT NULL, - "MaterializerContext" TEXT NULL, - "StringData" TEXT NULL, - "BinaryData" BLOB NULL, - "IsReadonly" INTEGER NOT NULL, - "Data" TEXT NULL, - "UsableAsActivity" INTEGER NULL, - "CreatedAt" TEXT NOT NULL, - "Version" INTEGER NOT NULL, - "IsLatest" INTEGER NOT NULL, - "IsPublished" INTEGER NOT NULL -); - -CREATE TABLE "WorkflowInstances" ( - "Id" TEXT NOT NULL CONSTRAINT "PK_WorkflowInstances" PRIMARY KEY, - "DefinitionId" TEXT NOT NULL, - "DefinitionVersionId" TEXT NOT NULL, - "Version" INTEGER NOT NULL, - "Status" TEXT NOT NULL, - "SubStatus" TEXT NOT NULL, - "CorrelationId" TEXT NULL, - "Name" TEXT NULL, - "IncidentCount" INTEGER NOT NULL, - "CreatedAt" TEXT NOT NULL, - "UpdatedAt" TEXT NOT NULL, - "FinishedAt" TEXT NULL, - "Data" TEXT NULL -); - -CREATE UNIQUE INDEX "IX_WorkflowDefinition_DefinitionId_Version" ON "WorkflowDefinitions" ("DefinitionId", "Version"); - -CREATE INDEX "IX_WorkflowDefinition_IsLatest" ON "WorkflowDefinitions" ("IsLatest"); - -CREATE INDEX "IX_WorkflowDefinition_IsPublished" ON "WorkflowDefinitions" ("IsPublished"); - -CREATE INDEX "IX_WorkflowDefinition_Name" ON "WorkflowDefinitions" ("Name"); - -CREATE INDEX "IX_WorkflowDefinition_UsableAsActivity" ON "WorkflowDefinitions" ("UsableAsActivity"); - -CREATE INDEX "IX_WorkflowDefinition_Version" ON "WorkflowDefinitions" ("Version"); - -CREATE INDEX "IX_WorkflowInstance_CorrelationId" ON "WorkflowInstances" ("CorrelationId"); - -CREATE INDEX "IX_WorkflowInstance_CreatedAt" ON "WorkflowInstances" ("CreatedAt"); - -CREATE INDEX "IX_WorkflowInstance_DefinitionId" ON "WorkflowInstances" ("DefinitionId"); - -CREATE INDEX "IX_WorkflowInstance_FinishedAt" ON "WorkflowInstances" ("FinishedAt"); - -CREATE INDEX "IX_WorkflowInstance_Name" ON "WorkflowInstances" ("Name"); - -CREATE INDEX "IX_WorkflowInstance_Status" ON "WorkflowInstances" ("Status"); - -CREATE INDEX "IX_WorkflowInstance_Status_DefinitionId" ON "WorkflowInstances" ("Status", "DefinitionId"); - -CREATE INDEX "IX_WorkflowInstance_Status_SubStatus" ON "WorkflowInstances" ("Status", "SubStatus"); - -CREATE INDEX "IX_WorkflowInstance_Status_SubStatus_DefinitionId_Version" ON "WorkflowInstances" ("Status", "SubStatus", "DefinitionId", "Version"); - -CREATE INDEX "IX_WorkflowInstance_SubStatus" ON "WorkflowInstances" ("SubStatus"); - -CREATE INDEX "IX_WorkflowInstance_SubStatus_DefinitionId" ON "WorkflowInstances" ("SubStatus", "DefinitionId"); - -CREATE INDEX "IX_WorkflowInstance_UpdatedAt" ON "WorkflowInstances" ("UpdatedAt"); - -INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion") -VALUES ('20231015122231_Initial', '7.0.14'); - -COMMIT; - -BEGIN TRANSACTION; - -ALTER TABLE "WorkflowInstances" ADD "DataCompressionAlgorithm" TEXT NULL; - -ALTER TABLE "WorkflowInstances" ADD "IsSystem" INTEGER NOT NULL DEFAULT 0; - -ALTER TABLE "WorkflowDefinitions" ADD "IsSystem" INTEGER NOT NULL DEFAULT 0; - -CREATE INDEX "IX_WorkflowInstance_IsSystem" ON "WorkflowInstances" ("IsSystem"); - -CREATE INDEX "IX_WorkflowDefinition_IsSystem" ON "WorkflowDefinitions" ("IsSystem"); - -INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion") -VALUES ('20240312145202_V3_1', '7.0.14'); - -COMMIT; - diff --git a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Runtime/20240312145142_V3_1.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Runtime/20240326133135_V3_1.Designer.cs similarity index 99% rename from src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Runtime/20240312145142_V3_1.Designer.cs rename to src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Runtime/20240326133135_V3_1.Designer.cs index 812c4fafdf..eb2a8ac521 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Runtime/20240312145142_V3_1.Designer.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Runtime/20240326133135_V3_1.Designer.cs @@ -10,7 +10,7 @@ namespace Elsa.EntityFrameworkCore.Sqlite.Migrations.Runtime { [DbContext(typeof(RuntimeElsaDbContext))] - [Migration("20240312145142_V3_1")] + [Migration("20240326133135_V3_1")] partial class V3_1 { /// diff --git a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Runtime/20240312145142_V3_1.cs b/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Runtime/20240326133135_V3_1.cs similarity index 100% rename from src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Runtime/20240312145142_V3_1.cs rename to src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Runtime/20240326133135_V3_1.cs diff --git a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Runtime/v3.1.sql b/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Runtime/v3.1.sql deleted file mode 100755 index b56150711e..0000000000 --- a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Runtime/v3.1.sql +++ /dev/null @@ -1,193 +0,0 @@ -CREATE TABLE IF NOT EXISTS "__EFMigrationsHistory" ( - "MigrationId" TEXT NOT NULL CONSTRAINT "PK___EFMigrationsHistory" PRIMARY KEY, - "ProductVersion" TEXT NOT NULL -); - -BEGIN TRANSACTION; - -CREATE TABLE "ActivityExecutionRecords" ( - "Id" TEXT NOT NULL CONSTRAINT "PK_ActivityExecutionRecords" PRIMARY KEY, - "WorkflowInstanceId" TEXT NOT NULL, - "ActivityId" TEXT NOT NULL, - "ActivityNodeId" TEXT NOT NULL, - "ActivityType" TEXT NOT NULL, - "ActivityTypeVersion" INTEGER NOT NULL, - "ActivityName" TEXT NULL, - "StartedAt" TEXT NOT NULL, - "HasBookmarks" INTEGER NOT NULL, - "Status" TEXT NOT NULL, - "CompletedAt" TEXT NULL, - "SerializedActivityState" TEXT NULL, - "SerializedException" TEXT NULL, - "SerializedOutputs" TEXT NULL, - "SerializedPayload" TEXT NULL -); - -CREATE TABLE "Bookmarks" ( - "BookmarkId" TEXT NOT NULL CONSTRAINT "PK_Bookmarks" PRIMARY KEY, - "ActivityTypeName" TEXT NOT NULL, - "Hash" TEXT NOT NULL, - "WorkflowInstanceId" TEXT NOT NULL, - "ActivityInstanceId" TEXT NULL, - "CorrelationId" TEXT NULL, - "CreatedAt" TEXT NOT NULL, - "SerializedMetadata" TEXT NULL, - "SerializedPayload" TEXT NULL -); - -CREATE TABLE "Triggers" ( - "Id" TEXT NOT NULL CONSTRAINT "PK_Triggers" PRIMARY KEY, - "WorkflowDefinitionId" TEXT NOT NULL, - "WorkflowDefinitionVersionId" TEXT NOT NULL, - "Name" TEXT NOT NULL, - "ActivityId" TEXT NOT NULL, - "Hash" TEXT NULL, - "SerializedPayload" TEXT NULL -); - -CREATE TABLE "WorkflowExecutionLogRecords" ( - "Id" TEXT NOT NULL CONSTRAINT "PK_WorkflowExecutionLogRecords" PRIMARY KEY, - "WorkflowDefinitionId" TEXT NOT NULL, - "WorkflowDefinitionVersionId" TEXT NOT NULL, - "WorkflowInstanceId" TEXT NOT NULL, - "WorkflowVersion" INTEGER NOT NULL, - "ActivityInstanceId" TEXT NOT NULL, - "ParentActivityInstanceId" TEXT NULL, - "ActivityId" TEXT NOT NULL, - "ActivityType" TEXT NOT NULL, - "ActivityTypeVersion" INTEGER NOT NULL, - "ActivityName" TEXT NULL, - "ActivityNodeId" TEXT NOT NULL, - "Timestamp" TEXT NOT NULL, - "Sequence" INTEGER NOT NULL, - "EventName" TEXT NULL, - "Message" TEXT NULL, - "Source" TEXT NULL, - "SerializedActivityState" TEXT NULL, - "SerializedPayload" TEXT NULL -); - -CREATE TABLE "WorkflowInboxMessages" ( - "Id" TEXT NOT NULL CONSTRAINT "PK_WorkflowInboxMessages" PRIMARY KEY, - "ActivityTypeName" TEXT NOT NULL, - "Hash" TEXT NOT NULL, - "WorkflowInstanceId" TEXT NULL, - "CorrelationId" TEXT NULL, - "ActivityInstanceId" TEXT NULL, - "CreatedAt" TEXT NOT NULL, - "ExpiresAt" TEXT NOT NULL, - "SerializedBookmarkPayload" TEXT NULL, - "SerializedInput" TEXT NULL -); - -CREATE INDEX "IX_ActivityExecutionRecord_ActivityId" ON "ActivityExecutionRecords" ("ActivityId"); - -CREATE INDEX "IX_ActivityExecutionRecord_ActivityName" ON "ActivityExecutionRecords" ("ActivityName"); - -CREATE INDEX "IX_ActivityExecutionRecord_ActivityNodeId" ON "ActivityExecutionRecords" ("ActivityNodeId"); - -CREATE INDEX "IX_ActivityExecutionRecord_ActivityType" ON "ActivityExecutionRecords" ("ActivityType"); - -CREATE INDEX "IX_ActivityExecutionRecord_ActivityType_ActivityTypeVersion" ON "ActivityExecutionRecords" ("ActivityType", "ActivityTypeVersion"); - -CREATE INDEX "IX_ActivityExecutionRecord_ActivityTypeVersion" ON "ActivityExecutionRecords" ("ActivityTypeVersion"); - -CREATE INDEX "IX_ActivityExecutionRecord_CompletedAt" ON "ActivityExecutionRecords" ("CompletedAt"); - -CREATE INDEX "IX_ActivityExecutionRecord_HasBookmarks" ON "ActivityExecutionRecords" ("HasBookmarks"); - -CREATE INDEX "IX_ActivityExecutionRecord_StartedAt" ON "ActivityExecutionRecords" ("StartedAt"); - -CREATE INDEX "IX_ActivityExecutionRecord_Status" ON "ActivityExecutionRecords" ("Status"); - -CREATE INDEX "IX_ActivityExecutionRecord_WorkflowInstanceId" ON "ActivityExecutionRecords" ("WorkflowInstanceId"); - -CREATE INDEX "IX_StoredBookmark_ActivityInstanceId" ON "Bookmarks" ("ActivityInstanceId"); - -CREATE INDEX "IX_StoredBookmark_ActivityTypeName" ON "Bookmarks" ("ActivityTypeName"); - -CREATE INDEX "IX_StoredBookmark_ActivityTypeName_Hash" ON "Bookmarks" ("ActivityTypeName", "Hash"); - -CREATE INDEX "IX_StoredBookmark_ActivityTypeName_Hash_WorkflowInstanceId" ON "Bookmarks" ("ActivityTypeName", "Hash", "WorkflowInstanceId"); - -CREATE INDEX "IX_StoredBookmark_CreatedAt" ON "Bookmarks" ("CreatedAt"); - -CREATE INDEX "IX_StoredBookmark_Hash" ON "Bookmarks" ("Hash"); - -CREATE INDEX "IX_StoredBookmark_WorkflowInstanceId" ON "Bookmarks" ("WorkflowInstanceId"); - -CREATE INDEX "IX_StoredTrigger_Hash" ON "Triggers" ("Hash"); - -CREATE INDEX "IX_StoredTrigger_Name" ON "Triggers" ("Name"); - -CREATE INDEX "IX_StoredTrigger_WorkflowDefinitionId" ON "Triggers" ("WorkflowDefinitionId"); - -CREATE INDEX "IX_StoredTrigger_WorkflowDefinitionVersionId" ON "Triggers" ("WorkflowDefinitionVersionId"); - -CREATE INDEX "IX_WorkflowExecutionLogRecord_ActivityId" ON "WorkflowExecutionLogRecords" ("ActivityId"); - -CREATE INDEX "IX_WorkflowExecutionLogRecord_ActivityInstanceId" ON "WorkflowExecutionLogRecords" ("ActivityInstanceId"); - -CREATE INDEX "IX_WorkflowExecutionLogRecord_ActivityName" ON "WorkflowExecutionLogRecords" ("ActivityName"); - -CREATE INDEX "IX_WorkflowExecutionLogRecord_ActivityNodeId" ON "WorkflowExecutionLogRecords" ("ActivityNodeId"); - -CREATE INDEX "IX_WorkflowExecutionLogRecord_ActivityType" ON "WorkflowExecutionLogRecords" ("ActivityType"); - -CREATE INDEX "IX_WorkflowExecutionLogRecord_ActivityType_ActivityTypeVersion" ON "WorkflowExecutionLogRecords" ("ActivityType", "ActivityTypeVersion"); - -CREATE INDEX "IX_WorkflowExecutionLogRecord_ActivityTypeVersion" ON "WorkflowExecutionLogRecords" ("ActivityTypeVersion"); - -CREATE INDEX "IX_WorkflowExecutionLogRecord_EventName" ON "WorkflowExecutionLogRecords" ("EventName"); - -CREATE INDEX "IX_WorkflowExecutionLogRecord_ParentActivityInstanceId" ON "WorkflowExecutionLogRecords" ("ParentActivityInstanceId"); - -CREATE INDEX "IX_WorkflowExecutionLogRecord_Sequence" ON "WorkflowExecutionLogRecords" ("Sequence"); - -CREATE INDEX "IX_WorkflowExecutionLogRecord_Timestamp" ON "WorkflowExecutionLogRecords" ("Timestamp"); - -CREATE INDEX "IX_WorkflowExecutionLogRecord_Timestamp_Sequence" ON "WorkflowExecutionLogRecords" ("Timestamp", "Sequence"); - -CREATE INDEX "IX_WorkflowExecutionLogRecord_WorkflowDefinitionId" ON "WorkflowExecutionLogRecords" ("WorkflowDefinitionId"); - -CREATE INDEX "IX_WorkflowExecutionLogRecord_WorkflowDefinitionVersionId" ON "WorkflowExecutionLogRecords" ("WorkflowDefinitionVersionId"); - -CREATE INDEX "IX_WorkflowExecutionLogRecord_WorkflowInstanceId" ON "WorkflowExecutionLogRecords" ("WorkflowInstanceId"); - -CREATE INDEX "IX_WorkflowExecutionLogRecord_WorkflowVersion" ON "WorkflowExecutionLogRecords" ("WorkflowVersion"); - -CREATE INDEX "IX_WorkflowInboxMessage_ActivityInstanceId" ON "WorkflowInboxMessages" ("ActivityInstanceId"); - -CREATE INDEX "IX_WorkflowInboxMessage_ActivityTypeName" ON "WorkflowInboxMessages" ("ActivityTypeName"); - -CREATE INDEX "IX_WorkflowInboxMessage_CorrelationId" ON "WorkflowInboxMessages" ("CorrelationId"); - -CREATE INDEX "IX_WorkflowInboxMessage_CreatedAt" ON "WorkflowInboxMessages" ("CreatedAt"); - -CREATE INDEX "IX_WorkflowInboxMessage_ExpiresAt" ON "WorkflowInboxMessages" ("ExpiresAt"); - -CREATE INDEX "IX_WorkflowInboxMessage_Hash" ON "WorkflowInboxMessages" ("Hash"); - -CREATE INDEX "IX_WorkflowInboxMessage_WorkflowInstanceId" ON "WorkflowInboxMessages" ("WorkflowInstanceId"); - -INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion") -VALUES ('20231024160948_Initial', '7.0.14'); - -COMMIT; - -BEGIN TRANSACTION; - -ALTER TABLE "ActivityExecutionRecords" ADD "SerializedActivityStateCompressionAlgorithm" TEXT NULL; - -ALTER TABLE "ActivityExecutionRecords" ADD "SerializedProperties" TEXT NULL; - -CREATE TABLE "KeyValuePairs" ( - "Key" TEXT NOT NULL CONSTRAINT "PK_KeyValuePairs" PRIMARY KEY, - "SerializedValue" TEXT NOT NULL -); - -INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion") -VALUES ('20240312145142_V3_1', '7.0.14'); - -COMMIT; - diff --git a/src/modules/Elsa.MassTransit.AzureServiceBus/Handlers/RemoveOrphanedSubscriptions.cs b/src/modules/Elsa.MassTransit.AzureServiceBus/Handlers/RemoveOrphanedSubscriptions.cs index 891be19199..e7276a8d6f 100644 --- a/src/modules/Elsa.MassTransit.AzureServiceBus/Handlers/RemoveOrphanedSubscriptions.cs +++ b/src/modules/Elsa.MassTransit.AzureServiceBus/Handlers/RemoveOrphanedSubscriptions.cs @@ -1,8 +1,10 @@ +using Azure.Messaging.ServiceBus; using Azure.Messaging.ServiceBus.Administration; using Elsa.Hosting.Management.Notifications; using Elsa.MassTransit.AzureServiceBus.Services; using Elsa.Mediator.Contracts; using JetBrains.Annotations; +using Microsoft.Extensions.Logging; namespace Elsa.MassTransit.AzureServiceBus.Handlers; @@ -10,7 +12,10 @@ namespace Elsa.MassTransit.AzureServiceBus.Handlers; /// A handler for the notification that removes orphaned subscriptions from Azure Service Bus. /// [UsedImplicitly] -public class RemoveOrphanedSubscriptions(MessageTopologyProvider topologyProvider, ServiceBusAdministrationClient client) : INotificationHandler +public class RemoveOrphanedSubscriptions(MessageTopologyProvider topologyProvider, + ServiceBusAdministrationClient client, + ILogger logger) + : INotificationHandler { /// /// Removes orphaned subscriptions from Azure Service Bus. @@ -21,19 +26,26 @@ public async Task HandleAsync(HeartbeatTimedOut notification, CancellationToken foreach (var subscription in subscriptionTopology) { - // Get subscriptions based on topics instead of the topology since when names are longer than 50 characters. - // MassTransit automatically truncates them. - await foreach (var asbSubscription in client.GetSubscriptionsAsync(subscription.TopicName, cancellationToken)) + try { - if (asbSubscription.SubscriptionName.StartsWith($"Elsa-{notification.InstanceName}-")) + // Get subscriptions based on topics instead of the topology since when names are longer than 50 characters. + // MassTransit automatically truncates them. + await foreach (var asbSubscription in client.GetSubscriptionsAsync(subscription.TopicName, cancellationToken)) { - var queueName = asbSubscription.ForwardTo[(asbSubscription.ForwardTo.LastIndexOf('/') + 1)..]; + if (asbSubscription.SubscriptionName.StartsWith($"Elsa-{notification.InstanceName}-")) + { + var queueName = asbSubscription.ForwardTo[(asbSubscription.ForwardTo.LastIndexOf('/') + 1)..]; - await Task.WhenAll( - client.DeleteSubscriptionAsync(subscription.TopicName, asbSubscription.SubscriptionName, cancellationToken), - client.DeleteQueueAsync(queueName, cancellationToken)); + await Task.WhenAll( + client.DeleteSubscriptionAsync(subscription.TopicName, asbSubscription.SubscriptionName, cancellationToken), + client.DeleteQueueAsync(queueName, cancellationToken)); + } } } + catch (ServiceBusException ex) when(ex.Reason == ServiceBusFailureReason.MessagingEntityNotFound) + { + logger.LogWarning(ex, $"Service bus entity {ex.EntityPath} was not found"); + } } } } \ No newline at end of file diff --git a/src/modules/Elsa.MassTransit/Consumers/DispatchCancelWorkflowsRequestConsumer.cs b/src/modules/Elsa.MassTransit/Consumers/DispatchCancelWorkflowsRequestConsumer.cs index 536d02b137..886e12f7a4 100644 --- a/src/modules/Elsa.MassTransit/Consumers/DispatchCancelWorkflowsRequestConsumer.cs +++ b/src/modules/Elsa.MassTransit/Consumers/DispatchCancelWorkflowsRequestConsumer.cs @@ -12,8 +12,8 @@ public class DispatchCancelWorkflowsRequestConsumer(IWorkflowRuntime workflowRun /// public async Task Consume(ConsumeContext context) { - var message = context.Message; - - // TODO: Implement cancellation. + var request = context.Message; + + await workflowRuntime.CancelWorkflowAsync(request.WorkflowInstanceId); } } \ No newline at end of file diff --git a/src/modules/Elsa.MassTransit/Consumers/DispatchWorkflowRequestConsumer.cs b/src/modules/Elsa.MassTransit/Consumers/DispatchWorkflowRequestConsumer.cs index 28e1f74470..3af675ebe5 100644 --- a/src/modules/Elsa.MassTransit/Consumers/DispatchWorkflowRequestConsumer.cs +++ b/src/modules/Elsa.MassTransit/Consumers/DispatchWorkflowRequestConsumer.cs @@ -34,6 +34,7 @@ public async Task Consume(ConsumeContext context) var cancellationToken = context.CancellationToken; var options = new StartWorkflowRuntimeParams { + ParentWorkflowInstanceId = message.ParentWorkflowInstanceId, CorrelationId = message.CorrelationId, Input = message.Input, Properties = message.Properties, diff --git a/src/modules/Elsa.MassTransit/Messages/DispatchWorkflowDefinition.cs b/src/modules/Elsa.MassTransit/Messages/DispatchWorkflowDefinition.cs index b538e521d6..e4c204c165 100644 --- a/src/modules/Elsa.MassTransit/Messages/DispatchWorkflowDefinition.cs +++ b/src/modules/Elsa.MassTransit/Messages/DispatchWorkflowDefinition.cs @@ -7,6 +7,7 @@ namespace Elsa.MassTransit.Messages; /// /// The ID of the workflow definition to dispatch. /// The version options to use when dispatching the workflow definition. +/// The ID of the parent workflow instance. /// Any input to pass to the workflow. /// Any properties to attach to the workflow. /// A correlation ID to associate the workflow with. @@ -15,6 +16,7 @@ namespace Elsa.MassTransit.Messages; public record DispatchWorkflowDefinition( string DefinitionId, VersionOptions VersionOptions, + string? ParentWorkflowInstanceId, IDictionary? Input, IDictionary? Properties, string? CorrelationId, diff --git a/src/modules/Elsa.MassTransit/Services/MassTransitWorkflowDispatcher.cs b/src/modules/Elsa.MassTransit/Services/MassTransitWorkflowDispatcher.cs index 37f17a8a20..a09c6bd3cc 100644 --- a/src/modules/Elsa.MassTransit/Services/MassTransitWorkflowDispatcher.cs +++ b/src/modules/Elsa.MassTransit/Services/MassTransitWorkflowDispatcher.cs @@ -33,6 +33,7 @@ public async Task DispatchAsync(DispatchWorkflowDefini await sendEndpoint.Send(new DispatchWorkflowDefinition( request.DefinitionId, request.VersionOptions, + request.ParentWorkflowInstanceId, request.Input, request.Properties, request.CorrelationId, diff --git a/src/modules/Elsa.MongoDb/Modules/Management/WorkflowInstanceStore.cs b/src/modules/Elsa.MongoDb/Modules/Management/WorkflowInstanceStore.cs index 4ff9504980..d3aef30106 100644 --- a/src/modules/Elsa.MongoDb/Modules/Management/WorkflowInstanceStore.cs +++ b/src/modules/Elsa.MongoDb/Modules/Management/WorkflowInstanceStore.cs @@ -1,3 +1,4 @@ +using System.Diagnostics.CodeAnalysis; using Elsa.Common.Models; using Elsa.Extensions; using Elsa.MongoDb.Common; @@ -142,6 +143,7 @@ public async ValueTask SaveManyAsync(IEnumerable instances, Ca await _mongoDbStore.SaveManyAsync(instances.Select(i => i), cancellationToken); } + [RequiresUnreferencedCode("Calls Elsa.Workflows.Management.Filters.WorkflowInstanceFilter.Apply(IQueryable)")] private IMongoQueryable Filter(IQueryable queryable, WorkflowInstanceFilter filter) { return (filter.Apply(queryable.Select(i => i)) as IMongoQueryable)!; diff --git a/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowInstances/Cancel/Endpoint.cs b/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowInstances/Cancel/Endpoint.cs index 478038e324..fc88984d9a 100644 --- a/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowInstances/Cancel/Endpoint.cs +++ b/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowInstances/Cancel/Endpoint.cs @@ -1,21 +1,14 @@ using Elsa.Abstractions; using Elsa.Workflows.Runtime.Contracts; -using Elsa.Workflows.Runtime.Models; using JetBrains.Annotations; using Microsoft.AspNetCore.Http; namespace Elsa.Workflows.Api.Endpoints.WorkflowInstances.Cancel; [PublicAPI] -internal class Cancel : ElsaEndpoint +internal class Cancel(IWorkflowCancellationService workflowCancellationService) + : ElsaEndpoint { - private readonly IWorkflowRuntime _workflowRuntime; - - public Cancel(IWorkflowRuntime workflowRuntime) - { - _workflowRuntime = workflowRuntime; - } - public override void Configure() { Post("/cancel/workflow-instances/{id}"); @@ -26,20 +19,8 @@ public override void Configure() public override async Task HandleAsync(Request request, CancellationToken cancellationToken) { - var result = await _workflowRuntime.CancelWorkflowAsync(request.Id, cancellationToken); + await workflowCancellationService.CancelWorkflowAsync(request.Id, cancellationToken); - if (result.Result) - await SendOkAsync(cancellationToken); - else if (result.Reason == FailureReason.NotFound) - await SendNotFoundAsync(cancellationToken); - else - { - if (result.Reason == FailureReason.InvalidState) - AddError("Instance is in finished state."); - else - AddError("Unable to access instance."); - - await SendErrorsAsync(StatusCodes.Status409Conflict, cancellationToken); - } + await SendOkAsync(cancellationToken); } } \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowInstances/Get/Mappers.cs b/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowInstances/Get/Mappers.cs index fd0a7e4dd3..e22c3da9c6 100644 --- a/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowInstances/Get/Mappers.cs +++ b/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowInstances/Get/Mappers.cs @@ -16,6 +16,7 @@ internal class WorkflowInstanceMapper : ResponseMapper public int Version { get; set; } + + /// + /// The ID of the parent workflow instance. + /// + public string? ParentWorkflowInstanceId { get; set; } /// /// The state of the workflow instance. diff --git a/src/modules/Elsa.Workflows.Core/Contexts/WorkflowExecutionContext.cs b/src/modules/Elsa.Workflows.Core/Contexts/WorkflowExecutionContext.cs index 9e0335a130..639a96e8c9 100644 --- a/src/modules/Elsa.Workflows.Core/Contexts/WorkflowExecutionContext.cs +++ b/src/modules/Elsa.Workflows.Core/Contexts/WorkflowExecutionContext.cs @@ -46,6 +46,7 @@ private WorkflowExecutionContext( IServiceProvider serviceProvider, string id, string? correlationId, + string? parentWorkflowInstanceId, IDictionary? input, IDictionary? properties, ExecuteActivityDelegate? executeDelegate, @@ -62,6 +63,7 @@ private WorkflowExecutionContext( SubStatus = WorkflowSubStatus.Pending; Id = id; CorrelationId = correlationId; + ParentWorkflowInstanceId = parentWorkflowInstanceId; _activityExecutionContexts = new List(); Scheduler = serviceProvider.GetRequiredService().CreateScheduler(); IdentityGenerator = serviceProvider.GetRequiredService(); @@ -90,6 +92,7 @@ public static async Task CreateAsync( Workflow workflow, string id, string? correlationId, + string? parentWorkflowInstanceId = default, IDictionary? input = default, IDictionary? properties = default, ExecuteActivityDelegate? executeDelegate = default, @@ -106,6 +109,7 @@ public static async Task CreateAsync( new List(), systemClock.UtcNow, correlationId, + parentWorkflowInstanceId, input, properties, executeDelegate, @@ -123,6 +127,7 @@ public static async Task CreateAsync( Workflow workflow, WorkflowState workflowState, string? correlationId = default, + string? parentWorkflowInstanceId = default, IDictionary? input = default, IDictionary? properties = default, ExecuteActivityDelegate? executeDelegate = default, @@ -137,6 +142,7 @@ public static async Task CreateAsync( workflowState.Incidents, workflowState.CreatedAt, correlationId, + parentWorkflowInstanceId, input, properties, executeDelegate, @@ -160,6 +166,7 @@ public static async Task CreateAsync( IEnumerable incidents, DateTimeOffset createdAt, string? correlationId = default, + string? parentWorkflowInstanceId = default, IDictionary? input = default, IDictionary? properties = default, ExecuteActivityDelegate? executeDelegate = default, @@ -172,6 +179,7 @@ public static async Task CreateAsync( serviceProvider, id, correlationId, + parentWorkflowInstanceId, input, properties, executeDelegate, @@ -271,6 +279,11 @@ public async Task SetWorkflowAsync(Workflow workflow) /// An application-specific identifier associated with the execution context. /// public string? CorrelationId { get; set; } + + /// + /// The ID of the workflow instance that triggered this instance. + /// + public string? ParentWorkflowInstanceId { get; set; } /// /// The date and time the workflow execution context was created. diff --git a/src/modules/Elsa.Workflows.Core/Options/RunWorkflowOptions.cs b/src/modules/Elsa.Workflows.Core/Options/RunWorkflowOptions.cs index fc4a9d20c7..4204b46664 100644 --- a/src/modules/Elsa.Workflows.Core/Options/RunWorkflowOptions.cs +++ b/src/modules/Elsa.Workflows.Core/Options/RunWorkflowOptions.cs @@ -19,4 +19,5 @@ public class RunWorkflowOptions public string? TriggerActivityId { get; set; } public CancellationTokens CancellationTokens { get; set; } public Action? StatusUpdatedCallback { get; set; } + public string? ParentWorkflowInstanceId { get; set; } } \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Core/Services/WorkflowRunner.cs b/src/modules/Elsa.Workflows.Core/Services/WorkflowRunner.cs index 14e988d64e..fdd06d7e56 100644 --- a/src/modules/Elsa.Workflows.Core/Services/WorkflowRunner.cs +++ b/src/modules/Elsa.Workflows.Core/Services/WorkflowRunner.cs @@ -94,12 +94,14 @@ public async Task RunAsync(Workflow workflow, RunWorkflowOpti var properties = options?.Properties; var correlationId = options?.CorrelationId; var triggerActivityId = options?.TriggerActivityId; + var parentWorkflowInstanceId = options?.ParentWorkflowInstanceId; var statusUpdatedCallback = options?.StatusUpdatedCallback; var workflowExecutionContext = await WorkflowExecutionContext.CreateAsync( scope.ServiceProvider, workflow, instanceId, correlationId, + parentWorkflowInstanceId, input, properties, default, @@ -124,12 +126,14 @@ public async Task RunAsync(Workflow workflow, WorkflowState w var properties = options?.Properties; var correlationId = options?.CorrelationId ?? workflowState.CorrelationId; var triggerActivityId = options?.TriggerActivityId; + var parentWorkflowInstanceId = options?.ParentWorkflowInstanceId; var statusUpdatedCallback = options?.StatusUpdatedCallback; var workflowExecutionContext = await WorkflowExecutionContext.CreateAsync( scope.ServiceProvider, workflow, workflowState, correlationId, + parentWorkflowInstanceId, input, properties, default, diff --git a/src/modules/Elsa.Workflows.Core/Services/WorkflowStateExtractor.cs b/src/modules/Elsa.Workflows.Core/Services/WorkflowStateExtractor.cs index c7b3930156..998ef3d41b 100644 --- a/src/modules/Elsa.Workflows.Core/Services/WorkflowStateExtractor.cs +++ b/src/modules/Elsa.Workflows.Core/Services/WorkflowStateExtractor.cs @@ -18,6 +18,7 @@ public WorkflowState Extract(WorkflowExecutionContext workflowExecutionContext) DefinitionVersionId = workflowExecutionContext.Workflow.Identity.Id, DefinitionVersion = workflowExecutionContext.Workflow.Identity.Version, CorrelationId = workflowExecutionContext.CorrelationId, + ParentWorkflowInstanceId = workflowExecutionContext.ParentWorkflowInstanceId, Status = workflowExecutionContext.Status, SubStatus = workflowExecutionContext.SubStatus, Bookmarks = workflowExecutionContext.Bookmarks, @@ -44,6 +45,7 @@ public WorkflowExecutionContext Apply(WorkflowExecutionContext workflowExecution { workflowExecutionContext.Id = state.Id; workflowExecutionContext.CorrelationId = state.CorrelationId; + workflowExecutionContext.ParentWorkflowInstanceId = state.ParentWorkflowInstanceId; workflowExecutionContext.SubStatus = state.SubStatus; workflowExecutionContext.Bookmarks = state.Bookmarks; workflowExecutionContext.Output = state.Output; diff --git a/src/modules/Elsa.Workflows.Core/State/WorkflowState.cs b/src/modules/Elsa.Workflows.Core/State/WorkflowState.cs index ec573a00b3..3bb07a0433 100644 --- a/src/modules/Elsa.Workflows.Core/State/WorkflowState.cs +++ b/src/modules/Elsa.Workflows.Core/State/WorkflowState.cs @@ -28,6 +28,11 @@ public class WorkflowState /// public int DefinitionVersion { get; set; } + /// + /// The ID of the parent workflow. + /// + public string? ParentWorkflowInstanceId { get; set; } + /// /// The correlation ID of the workflow, if any. /// diff --git a/src/modules/Elsa.Workflows.Management/Entities/WorkflowInstance.cs b/src/modules/Elsa.Workflows.Management/Entities/WorkflowInstance.cs index 7a38c031ed..759df20253 100644 --- a/src/modules/Elsa.Workflows.Management/Entities/WorkflowInstance.cs +++ b/src/modules/Elsa.Workflows.Management/Entities/WorkflowInstance.cs @@ -22,6 +22,11 @@ public class WorkflowInstance : Entity /// The version of the workflow definition. /// public int Version { get; set; } + + /// + /// The ID of the parent workflow. + /// + public string? ParentWorkflowInstanceId { get; set; } /// /// The state of the workflow instance. diff --git a/src/modules/Elsa.Workflows.Management/Filters/WorkflowInstanceFilter.cs b/src/modules/Elsa.Workflows.Management/Filters/WorkflowInstanceFilter.cs index 18fddc9357..e578468c5f 100644 --- a/src/modules/Elsa.Workflows.Management/Filters/WorkflowInstanceFilter.cs +++ b/src/modules/Elsa.Workflows.Management/Filters/WorkflowInstanceFilter.cs @@ -50,6 +50,11 @@ public class WorkflowInstanceFilter /// Filter workflow instances by version. /// public int? Version { get; set; } + + /// + /// Filter workflow instances by their parent instance IDs. + /// + public ICollection? ParentWorkflowInstanceIds { get; set; } /// /// Filter workflow instances by correlation ID. @@ -111,6 +116,7 @@ public IQueryable Apply(IQueryable query) if (filter.DefinitionIds != null) query = query.Where(x => filter.DefinitionIds.Contains(x.DefinitionId)); if (filter.DefinitionVersionIds != null) query = query.Where(x => filter.DefinitionVersionIds.Contains(x.DefinitionVersionId)); if (filter.Version != null) query = query.Where(x => x.Version == filter.Version); + if (filter.ParentWorkflowInstanceIds != null) query = query.Where(x => x.ParentWorkflowInstanceId != null && filter.ParentWorkflowInstanceIds.Contains(x.ParentWorkflowInstanceId)); if (!string.IsNullOrWhiteSpace(filter.CorrelationId)) query = query.Where(x => x.CorrelationId == filter.CorrelationId); if (filter.CorrelationIds != null) query = query.Where(x => filter.CorrelationIds.Contains(x.CorrelationId!)); if (filter.WorkflowStatus != null) query = query.Where(x => x.Status == filter.WorkflowStatus); diff --git a/src/modules/Elsa.Workflows.Management/Mappers/WorkflowStateMapper.cs b/src/modules/Elsa.Workflows.Management/Mappers/WorkflowStateMapper.cs index ec84ec89ef..2efcd5e2fa 100644 --- a/src/modules/Elsa.Workflows.Management/Mappers/WorkflowStateMapper.cs +++ b/src/modules/Elsa.Workflows.Management/Mappers/WorkflowStateMapper.cs @@ -25,6 +25,7 @@ public class WorkflowStateMapper DefinitionId = source.DefinitionId, DefinitionVersionId = source.DefinitionVersionId, Version = source.DefinitionVersion, + ParentWorkflowInstanceId = source.ParentWorkflowInstanceId, Status = source.Status, SubStatus = source.SubStatus, CorrelationId = source.CorrelationId, @@ -55,6 +56,7 @@ public class WorkflowStateMapper workflowState.DefinitionId = source.DefinitionId; workflowState.DefinitionVersionId = source.DefinitionVersionId; workflowState.DefinitionVersion = source.Version; + workflowState.ParentWorkflowInstanceId = source.ParentWorkflowInstanceId; workflowState.Status = source.Status; workflowState.SubStatus = source.SubStatus; workflowState.CorrelationId = source.CorrelationId; diff --git a/src/modules/Elsa.Workflows.Management/Services/MemoryWorkflowInstanceStore.cs b/src/modules/Elsa.Workflows.Management/Services/MemoryWorkflowInstanceStore.cs index 284a6ba019..f1f92a0552 100644 --- a/src/modules/Elsa.Workflows.Management/Services/MemoryWorkflowInstanceStore.cs +++ b/src/modules/Elsa.Workflows.Management/Services/MemoryWorkflowInstanceStore.cs @@ -1,3 +1,4 @@ +using System.Diagnostics.CodeAnalysis; using Elsa.Common.Models; using Elsa.Common.Services; using Elsa.Extensions; @@ -144,5 +145,6 @@ public ValueTask DeleteAsync(WorkflowInstanceFilter filter, CancellationTo private static string GetId(WorkflowInstance workflowInstance) => workflowInstance.Id; + [RequiresUnreferencedCode("Calls Elsa.Workflows.Management.Filters.WorkflowInstanceFilter.Apply(IQueryable)")] private static IQueryable Filter(IQueryable query, WorkflowInstanceFilter filter) => filter.Apply(query); } \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Runtime/Activities/BulkDispatchWorkflows.cs b/src/modules/Elsa.Workflows.Runtime/Activities/BulkDispatchWorkflows.cs index 86a0822cd9..1340a3facf 100644 --- a/src/modules/Elsa.Workflows.Runtime/Activities/BulkDispatchWorkflows.cs +++ b/src/modules/Elsa.Workflows.Runtime/Activities/BulkDispatchWorkflows.cs @@ -184,6 +184,7 @@ private async ValueTask DispatchChildWorkflowAsync(ActivityExecutionCont { DefinitionId = workflowDefinitionId, VersionOptions = VersionOptions.Published, + ParentWorkflowInstanceId = parentInstanceId, Input = input, Properties = properties, CorrelationId = correlationId, diff --git a/src/modules/Elsa.Workflows.Runtime/Activities/DispatchWorkflow.cs b/src/modules/Elsa.Workflows.Runtime/Activities/DispatchWorkflow.cs index eff1280c36..b577115954 100644 --- a/src/modules/Elsa.Workflows.Runtime/Activities/DispatchWorkflow.cs +++ b/src/modules/Elsa.Workflows.Runtime/Activities/DispatchWorkflow.cs @@ -111,6 +111,7 @@ private async ValueTask DispatchChildWorkflowAsync(ActivityExecutionCont { DefinitionId = workflowDefinitionId, VersionOptions = VersionOptions.Published, + ParentWorkflowInstanceId = context.WorkflowExecutionContext.Id, Input = input, CorrelationId = correlationId, InstanceId = instanceId, diff --git a/src/modules/Elsa.Workflows.Runtime/Commands/DispatchWorkflowDefinitionCommand.cs b/src/modules/Elsa.Workflows.Runtime/Commands/DispatchWorkflowDefinitionCommand.cs index 47f954779a..aa741bdd23 100644 --- a/src/modules/Elsa.Workflows.Runtime/Commands/DispatchWorkflowDefinitionCommand.cs +++ b/src/modules/Elsa.Workflows.Runtime/Commands/DispatchWorkflowDefinitionCommand.cs @@ -11,6 +11,7 @@ public class DispatchWorkflowDefinitionCommand(string definitionId, VersionOptio { public string DefinitionId { get; init; } = definitionId; public VersionOptions VersionOptions { get; init; } = versionOptions; + public string? ParentWorkflowInstanceId { get; init; } public IDictionary? Input { get; set; } public IDictionary? Properties { get; set; } public string? CorrelationId { get; set; } diff --git a/src/modules/Elsa.Workflows.Runtime/Contracts/IWorkflowCancellationService.cs b/src/modules/Elsa.Workflows.Runtime/Contracts/IWorkflowCancellationService.cs index 0e0916470a..53b7d55887 100644 --- a/src/modules/Elsa.Workflows.Runtime/Contracts/IWorkflowCancellationService.cs +++ b/src/modules/Elsa.Workflows.Runtime/Contracts/IWorkflowCancellationService.cs @@ -7,18 +7,28 @@ namespace Elsa.Workflows.Runtime.Contracts; /// public interface IWorkflowCancellationService { + /// + /// Cancels a workflow instance. + /// + /// Also cancels all children + Task CancelWorkflowAsync(string workflowInstanceId, CancellationToken cancellationToken = default); + /// /// Cancels workflow executions with the specified workflow instance ID. /// + /// Also cancels all children Task CancelWorkflowsAsync(IEnumerable workflowInstanceIds, CancellationToken cancellationToken = default); /// /// Cancels all workflow instances by definition version ID. /// + /// Also cancels all children Task CancelWorkflowByDefinitionVersionAsync(string definitionVersionId, CancellationToken cancellationToken = default); /// /// Cancels all workflows that match the specified workflow definition by its ID and version. /// + /// Also cancels all children Task CancelWorkflowByDefinitionAsync(string definitionId, VersionOptions versionOptions, CancellationToken cancellationToken = default); + } \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Runtime/Handlers/CancelWorkflowsCommandCommandHandler.cs b/src/modules/Elsa.Workflows.Runtime/Handlers/CancelWorkflowsCommandHandler.cs similarity index 71% rename from src/modules/Elsa.Workflows.Runtime/Handlers/CancelWorkflowsCommandCommandHandler.cs rename to src/modules/Elsa.Workflows.Runtime/Handlers/CancelWorkflowsCommandHandler.cs index fab9a32f7f..08b872596c 100644 --- a/src/modules/Elsa.Workflows.Runtime/Handlers/CancelWorkflowsCommandCommandHandler.cs +++ b/src/modules/Elsa.Workflows.Runtime/Handlers/CancelWorkflowsCommandHandler.cs @@ -6,13 +6,15 @@ namespace Elsa.Workflows.Runtime.Handlers; /// -/// Handles the . +/// Handles the . /// public class CancelWorkflowsCommandHandler(IWorkflowRuntime workflowRuntime) : ICommandHandler { + /// public async Task HandleAsync(CancelWorkflowsCommand command, CancellationToken cancellationToken) { - // TODO: Implement cancellation. + await workflowRuntime.CancelWorkflowAsync(command.Request.WorkflowInstanceId, cancellationToken); + return Unit.Instance; } } \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Runtime/Parameters/StartWorkflowHostParams.cs b/src/modules/Elsa.Workflows.Runtime/Parameters/StartWorkflowHostParams.cs index 43fb18e5f9..a171179c28 100644 --- a/src/modules/Elsa.Workflows.Runtime/Parameters/StartWorkflowHostParams.cs +++ b/src/modules/Elsa.Workflows.Runtime/Parameters/StartWorkflowHostParams.cs @@ -29,4 +29,9 @@ public class StartWorkflowHostParams /// Callback method that will be called when the status of the workflow has been updated /// public Action? StatusUpdatedCallback { get; set; } + + /// + /// The ID of the parent workflow instance. + /// + public string? ParentWorkflowInstanceId { get; set; } } \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Runtime/Parameters/StartWorkflowRuntimeParams.cs b/src/modules/Elsa.Workflows.Runtime/Parameters/StartWorkflowRuntimeParams.cs index e04fe94b1c..b6a625a6df 100644 --- a/src/modules/Elsa.Workflows.Runtime/Parameters/StartWorkflowRuntimeParams.cs +++ b/src/modules/Elsa.Workflows.Runtime/Parameters/StartWorkflowRuntimeParams.cs @@ -21,4 +21,6 @@ public class StartWorkflowRuntimeParams public string? InstanceId { get; set; } public CancellationTokens CancellationTokens { get; set; } + + public string? ParentWorkflowInstanceId { get; set; } } \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Runtime/Requests/DispatchCancelWorkflowsRequest.cs b/src/modules/Elsa.Workflows.Runtime/Requests/DispatchCancelWorkflowsRequest.cs index e26f7bf66e..7a7d77a39f 100644 --- a/src/modules/Elsa.Workflows.Runtime/Requests/DispatchCancelWorkflowsRequest.cs +++ b/src/modules/Elsa.Workflows.Runtime/Requests/DispatchCancelWorkflowsRequest.cs @@ -1,35 +1,12 @@ -using Elsa.Common.Models; - namespace Elsa.Workflows.Runtime.Requests; /// /// A dispatch request that indicates that one or more workflows are requested to be cancelled. /// -/// -/// The various sets of properties on this request are mutually exclusive. Only one set of properties should be set. -/// For example, if you want to cancel a specific workflow instance, only set the property. -/// If you want to cancel all instances of a specific workflow definition, only set the property and the property. -/// And if you want to cancel all instances of a specific workflow definition version, only set the property. -/// public class DispatchCancelWorkflowsRequest { /// - /// The IDs of the workflow instances to cancel. - /// - public ICollection? WorkflowInstanceIds { get; set; } - - /// - /// The ID of the workflow definition to cancel. - /// - public string? DefinitionVersionId { get; set; } - - /// - /// The definition ID of the workflow definition to cancel. Use this in combination with the property. - /// - public string? DefinitionId { get; set; } - - /// - /// The version options to use when querying for workflow instances to cancel. Use this in combination with the property. + /// The ID of the workflow instance to cancel. /// - public VersionOptions? VersionOptions { get; set; } + public string WorkflowInstanceId { get; set; } = default!; } \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Runtime/Requests/DispatchWorkflowDefinitionRequest.cs b/src/modules/Elsa.Workflows.Runtime/Requests/DispatchWorkflowDefinitionRequest.cs index 103b0f7605..c20ee4a948 100644 --- a/src/modules/Elsa.Workflows.Runtime/Requests/DispatchWorkflowDefinitionRequest.cs +++ b/src/modules/Elsa.Workflows.Runtime/Requests/DispatchWorkflowDefinitionRequest.cs @@ -36,6 +36,11 @@ public DispatchWorkflowDefinitionRequest(string definitionId, VersionOptions ver /// The version options to use when dispatching the workflow definition. /// public VersionOptions VersionOptions { get; init; } + + /// + /// The ID of the parent workflow instance. + /// + public string? ParentWorkflowInstanceId { get; set; } /// /// Any input to pass to the workflow. diff --git a/src/modules/Elsa.Workflows.Runtime/Services/DefaultWorkflowRuntime.cs b/src/modules/Elsa.Workflows.Runtime/Services/DefaultWorkflowRuntime.cs index 62cde38d80..93a9795d7b 100644 --- a/src/modules/Elsa.Workflows.Runtime/Services/DefaultWorkflowRuntime.cs +++ b/src/modules/Elsa.Workflows.Runtime/Services/DefaultWorkflowRuntime.cs @@ -404,6 +404,7 @@ private async Task StartWorkflowAsync(IWorkflowHost wor var startWorkflowOptions = new StartWorkflowHostParams { InstanceId = workflowInstanceId, + ParentWorkflowInstanceId = options?.ParentWorkflowInstanceId, CorrelationId = correlationId, Input = input, Properties = options?.Properties, diff --git a/src/modules/Elsa.Workflows.Runtime/Services/WorkflowCancellationService.cs b/src/modules/Elsa.Workflows.Runtime/Services/WorkflowCancellationService.cs index 2f97791137..26ad26ddc9 100644 --- a/src/modules/Elsa.Workflows.Runtime/Services/WorkflowCancellationService.cs +++ b/src/modules/Elsa.Workflows.Runtime/Services/WorkflowCancellationService.cs @@ -1,7 +1,9 @@ using Elsa.Common.Models; +using Elsa.Extensions; using Elsa.Workflows.Management.Contracts; using Elsa.Workflows.Management.Filters; using Elsa.Workflows.Runtime.Contracts; +using Elsa.Workflows.Runtime.Requests; namespace Elsa.Workflows.Runtime.Services; @@ -9,15 +11,19 @@ namespace Elsa.Workflows.Runtime.Services; public class WorkflowCancellationService( IWorkflowDefinitionService workflowDefinitionService, IWorkflowInstanceStore workflowInstanceStore, - IWorkflowRuntime workflowRuntime) + IWorkflowCancellationDispatcher dispatcher) : IWorkflowCancellationService { /// - public async Task CancelWorkflowsAsync(IEnumerable workflowInstanceIds, CancellationToken cancellationToken = default) + public Task CancelWorkflowAsync(string workflowInstanceId, CancellationToken cancellationToken = default) { - var tasks = workflowInstanceIds.Select(id => workflowRuntime.CancelWorkflowAsync(id, cancellationToken)).ToList(); - await Task.WhenAll(tasks); - return tasks.Count(t => t.Result.Result); + return CancelWorkflows(new List{workflowInstanceId}, cancellationToken); + } + + /// + public Task CancelWorkflowsAsync(IEnumerable workflowInstanceIds, CancellationToken cancellationToken = default) + { + return CancelWorkflows(workflowInstanceIds, cancellationToken); } /// @@ -29,9 +35,9 @@ public async Task CancelWorkflowByDefinitionVersionAsync(string definitionV WorkflowStatus = WorkflowStatus.Running }; var instances = (await workflowInstanceStore.FindManyAsync(filter, cancellationToken)).ToList(); - await Task.WhenAll(instances.Select(instance => workflowRuntime.CancelWorkflowAsync(instance.Id, cancellationToken))); - - return instances.Count; + var instanceIds = instances.Select(i => i.Id).ToList(); + + return await CancelWorkflowsAsync(instanceIds, cancellationToken); } /// @@ -42,7 +48,48 @@ public async Task CancelWorkflowByDefinitionAsync(string definitionId, Vers if (workflowDefinition is null) return 0; - var result = await CancelWorkflowByDefinitionVersionAsync(workflowDefinition.Id, cancellationToken); - return result; + return await CancelWorkflowByDefinitionVersionAsync(workflowDefinition.Id, cancellationToken); + } + + private async Task CancelWorkflows(IEnumerable workflowInstanceIds, CancellationToken cancellationToken) + { + var ids = workflowInstanceIds.ToList(); + var tasks = new List(); + + foreach (string workflowInstanceId in ids) + { + tasks.Add(dispatcher.DispatchAsync(new DispatchCancelWorkflowsRequest + { + WorkflowInstanceId = workflowInstanceId + }, cancellationToken)); + } + + var childCount = await CancelChildWorkflowInstances(ids, cancellationToken); + await Task.WhenAll(tasks); + + return tasks.Count + childCount; + } + + private async Task CancelChildWorkflowInstances(IEnumerable workflowInstanceIds, CancellationToken cancellationToken) + { + var tasks = new List>(); + var workflowInstanceIdBatches = workflowInstanceIds.Chunk(50); + + foreach (var workflowInstanceIdBatch in workflowInstanceIdBatches) + { + // Find child instances for the current workflow instance ID and cancel them. + // Do not check on status as their children might still be running and need to be cancelled. + var filter = new WorkflowInstanceFilter + { + ParentWorkflowInstanceIds = workflowInstanceIdBatch.ToList() + }; + var childInstances = (await workflowInstanceStore.FindManyAsync(filter, cancellationToken)).ToList(); + + if (childInstances.Any()) + tasks.AddRange(CancelWorkflows(childInstances.Select(c => c.Id), cancellationToken)); + } + + await Task.WhenAll(tasks); + return tasks.Sum(t => t.Result); } } \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Runtime/Services/WorkflowHost.cs b/src/modules/Elsa.Workflows.Runtime/Services/WorkflowHost.cs index 2daa06e5e9..28a4313d4b 100644 --- a/src/modules/Elsa.Workflows.Runtime/Services/WorkflowHost.cs +++ b/src/modules/Elsa.Workflows.Runtime/Services/WorkflowHost.cs @@ -68,6 +68,7 @@ public async Task CanStartWorkflowAsync(StartWorkflowHostParams? @params = /// public async Task StartWorkflowAsync(StartWorkflowHostParams? @params = default, CancellationToken cancellationToken = default) { + var parentWorkflowInstanceId = @params?.ParentWorkflowInstanceId; var correlationId = @params?.CorrelationId; var instanceId = @params?.InstanceId ?? _identityGenerator.GenerateId(); var originalBookmarks = WorkflowState.Bookmarks.ToList(); @@ -77,6 +78,7 @@ public async Task StartWorkflowAsync(StartWorkflowHostP var runOptions = new RunWorkflowOptions { WorkflowInstanceId = instanceId, + ParentWorkflowInstanceId = parentWorkflowInstanceId, CorrelationId = correlationId, Input = input, Properties = properties, diff --git a/test/unit/Elsa.Common.Core/Elsa.Common.Core.csproj b/test/unit/Elsa.Common.Core/Elsa.Common.Core.csproj new file mode 100644 index 0000000000..0d2efc6518 --- /dev/null +++ b/test/unit/Elsa.Common.Core/Elsa.Common.Core.csproj @@ -0,0 +1,5 @@ + + + + + diff --git a/test/unit/Elsa.Common.Core/EnumerableExtensionsTests.cs b/test/unit/Elsa.Common.Core/EnumerableExtensionsTests.cs new file mode 100644 index 0000000000..3c1598fe8a --- /dev/null +++ b/test/unit/Elsa.Common.Core/EnumerableExtensionsTests.cs @@ -0,0 +1,29 @@ +using Elsa.Extensions; +using Xunit; + +namespace Elsa.Common.Core; + +public class EnumerableExtensionsTests +{ + [Fact] + public void ToBatches_ReturnsItemsInListOfPages() + { + var items = new List + { + 1, + 2, + 3, + 4, + 5 + }; + var batchSize = 2; + var batches = items.ToBatches(batchSize).ToList(); + + Assert.Equal(3, batches.Count); + Assert.Equal(2, batches.ElementAt(0).Count()); + Assert.Equal(2, batches.ElementAt(1).Count()); + Assert.Equal(1, batches.ElementAt(2).Count()); + Assert.Equal(3, batches.ElementAt(1).ElementAt(0)); + Assert.Equal(4, batches.ElementAt(1).ElementAt(1)); + } +} \ No newline at end of file