< Summary

Information
Class: Elsa.UserTasks.Persistence.EFCore.Migrations.UserTasksSchemaMigration
Assembly: Elsa.UserTasks.Persistence.EFCore
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.UserTasks.Persistence.EFCore/Migrations/UserTasksSchemaMigration.cs
Line coverage
95%
Covered lines: 227
Uncovered lines: 10
Coverable lines: 237
Total lines: 265
Line coverage: 95.7%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Up(...)100%11100%
Down(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.UserTasks.Persistence.EFCore/Migrations/UserTasksSchemaMigration.cs

#LineLine coverage
 1using Microsoft.EntityFrameworkCore.Migrations;
 2
 3namespace Elsa.UserTasks.Persistence.EFCore.Migrations;
 4
 5/// <summary>
 6/// Provider-neutral initial schema operations. Provider migration assemblies call this helper so their
 7/// generated migration shape stays functionally identical while EF chooses provider column types.
 8/// </summary>
 9public static class UserTasksSchemaMigration
 10{
 11    public static void Up(MigrationBuilder migrationBuilder, string schema)
 12    {
 513        migrationBuilder.EnsureSchema(schema);
 14
 515        migrationBuilder.CreateTable(name: "UserTasks", schema: schema,
 516            columns: table => new
 517            {
 518                Id = table.Column<string>(maxLength: 450, nullable: false),
 519                TenantId = table.Column<string>(maxLength: 450, nullable: false),
 520                WorkflowDefinitionId = table.Column<string>(maxLength: 450, nullable: false),
 521                WorkflowDefinitionName = table.Column<string>(maxLength: 500, nullable: true),
 522                WorkflowDefinitionVersion = table.Column<int>(nullable: true),
 523                WorkflowInstanceId = table.Column<string>(maxLength: 450, nullable: false),
 524                WorkflowInstanceReference = table.Column<string>(maxLength: 500, nullable: true),
 525                ActivityInstanceId = table.Column<string>(maxLength: 450, nullable: false),
 526                BookmarkId = table.Column<string>(maxLength: 450, nullable: false),
 527                MaterializationKey = table.Column<string>(maxLength: 900, nullable: false),
 528                Title = table.Column<string>(maxLength: 500, nullable: false),
 529                Summary = table.Column<string>(maxLength: 4000, nullable: true),
 530                Reference = table.Column<string>(maxLength: 500, nullable: true),
 531                TaskType = table.Column<string>(maxLength: 200, nullable: true),
 532                TagsJson = table.Column<string>(nullable: false),
 533                RequesterProvider = table.Column<string>(maxLength: 200, nullable: true),
 534                RequesterType = table.Column<string>(maxLength: 64, nullable: true),
 535                RequesterId = table.Column<string>(maxLength: 450, nullable: true),
 536                RequesterDisplayName = table.Column<string>(maxLength: 500, nullable: true),
 537                Priority = table.Column<int>(nullable: false),
 538                DueAt = table.Column<DateTimeOffset>(nullable: true),
 539                IsOverdue = table.Column<bool>(nullable: false),
 540                Status = table.Column<string>(maxLength: 32, nullable: false),
 541                TimeoutEnabled = table.Column<bool>(nullable: false),
 542                CancellationEnabled = table.Column<bool>(nullable: false),
 543                AllowManagerExclusionOverride = table.Column<bool>(nullable: false),
 544                MembershipResolutionMode = table.Column<string>(maxLength: 32, nullable: true),
 545                AssigneeProvider = table.Column<string>(maxLength: 200, nullable: true),
 546                AssigneeType = table.Column<string>(maxLength: 64, nullable: true),
 547                AssigneeId = table.Column<string>(maxLength: 450, nullable: true),
 548                AssigneeDisplayName = table.Column<string>(maxLength: 500, nullable: true),
 549                InstructionsJson = table.Column<string>(nullable: false),
 550                TaskDataJson = table.Column<string>(nullable: false),
 551                FormReferenceJson = table.Column<string>(nullable: true),
 552                PinnedFormJson = table.Column<string>(nullable: true),
 553                ActionsJson = table.Column<string>(nullable: true),
 554                InvitationDefinitionsJson = table.Column<string>(nullable: false),
 555                HealthIssuesJson = table.Column<string>(nullable: false),
 556                HealthSeverity = table.Column<string>(maxLength: 32, nullable: true),
 557                HealthCode = table.Column<string>(maxLength: 200, nullable: true),
 558                HealthMessage = table.Column<string>(maxLength: 4000, nullable: true),
 559                CompletionActionKey = table.Column<string>(maxLength: 200, nullable: true),
 560                CompletionDataJson = table.Column<string>(nullable: true),
 561                CompletionActorJson = table.Column<string>(nullable: true),
 562                CreatedAt = table.Column<DateTimeOffset>(nullable: false),
 563                UpdatedAt = table.Column<DateTimeOffset>(nullable: false),
 564                AssignedAt = table.Column<DateTimeOffset>(nullable: true),
 565                CompletedAt = table.Column<DateTimeOffset>(nullable: true),
 566                Revision = table.Column<int>(nullable: false),
 567                CreatedFromBookmarkRevision = table.Column<long>(nullable: true)
 568            },
 1069            constraints: table => table.PrimaryKey("PK_UserTasks", x => x.Id));
 70
 571        migrationBuilder.CreateTable(name: "UserTaskCandidates", schema: schema,
 572            columns: table => new
 573            {
 574                Id = table.Column<string>(maxLength: 450, nullable: false),
 575                TenantId = table.Column<string>(maxLength: 450, nullable: false),
 576                TaskId = table.Column<string>(maxLength: 450, nullable: false),
 577                Provider = table.Column<string>(maxLength: 200, nullable: false),
 578                ParticipantKey = table.Column<string>(maxLength: 800, nullable: false),
 579                ParticipantType = table.Column<string>(maxLength: 32, nullable: false),
 580                ParticipantId = table.Column<string>(maxLength: 450, nullable: false),
 581                DisplayName = table.Column<string>(maxLength: 500, nullable: true),
 582                Source = table.Column<string>(maxLength: 32, nullable: false),
 583                SourceGroupProvider = table.Column<string>(maxLength: 200, nullable: true),
 584                SourceGroupId = table.Column<string>(maxLength: 450, nullable: true),
 585                CreatedAt = table.Column<DateTimeOffset>(nullable: false),
 586                UpdatedAt = table.Column<DateTimeOffset>(nullable: false)
 587            },
 1088            constraints: table => table.PrimaryKey("PK_UserTaskCandidates", x => x.Id));
 89
 590        migrationBuilder.CreateTable(name: "UserTaskSnapshotMembers", schema: schema,
 591            columns: table => new
 592            {
 593                Id = table.Column<string>(maxLength: 450, nullable: false),
 594                TenantId = table.Column<string>(maxLength: 450, nullable: false),
 595                TaskId = table.Column<string>(maxLength: 450, nullable: false),
 596                Provider = table.Column<string>(maxLength: 200, nullable: false),
 597                ParticipantKey = table.Column<string>(maxLength: 800, nullable: false),
 598                ParticipantType = table.Column<string>(maxLength: 32, nullable: false),
 599                ParticipantId = table.Column<string>(maxLength: 450, nullable: false),
 5100                SourceGroupProvider = table.Column<string>(maxLength: 200, nullable: true),
 5101                SourceGroupId = table.Column<string>(maxLength: 450, nullable: true),
 5102                CreatedAt = table.Column<DateTimeOffset>(nullable: false)
 5103            },
 10104            constraints: table => table.PrimaryKey("PK_UserTaskSnapshotMembers", x => x.Id));
 105
 5106        migrationBuilder.CreateTable(name: "UserTaskExclusions", schema: schema,
 5107            columns: table => new
 5108            {
 5109                Id = table.Column<string>(maxLength: 450, nullable: false),
 5110                TenantId = table.Column<string>(maxLength: 450, nullable: false),
 5111                TaskId = table.Column<string>(maxLength: 450, nullable: false),
 5112                Provider = table.Column<string>(maxLength: 200, nullable: false),
 5113                ParticipantKey = table.Column<string>(maxLength: 800, nullable: false),
 5114                ParticipantType = table.Column<string>(maxLength: 32, nullable: false),
 5115                ParticipantId = table.Column<string>(maxLength: 450, nullable: false),
 5116                CreatedAt = table.Column<DateTimeOffset>(nullable: false)
 5117            },
 10118            constraints: table => table.PrimaryKey("PK_UserTaskExclusions", x => x.Id));
 119
 5120        migrationBuilder.CreateTable(name: "UserTaskEvents", schema: schema,
 5121            columns: table => new
 5122            {
 5123                Id = table.Column<string>(maxLength: 450, nullable: false),
 5124                TenantId = table.Column<string>(maxLength: 450, nullable: false),
 5125                TaskId = table.Column<string>(maxLength: 450, nullable: false),
 5126                Revision = table.Column<int>(nullable: false),
 5127                EventType = table.Column<string>(maxLength: 64, nullable: false),
 5128                OccurredAt = table.Column<DateTimeOffset>(nullable: false),
 5129                OperationId = table.Column<string>(maxLength: 450, nullable: true),
 5130                ActorProvider = table.Column<string>(maxLength: 200, nullable: true),
 5131                ActorType = table.Column<string>(maxLength: 64, nullable: true),
 5132                ActorId = table.Column<string>(maxLength: 450, nullable: true),
 5133                ActorJson = table.Column<string>(nullable: true),
 5134                Reason = table.Column<string>(maxLength: 4000, nullable: true),
 5135                MetadataJson = table.Column<string>(nullable: false)
 5136            },
 10137            constraints: table => table.PrimaryKey("PK_UserTaskEvents", x => x.Id));
 138
 5139        migrationBuilder.CreateTable(name: "UserTaskOperations", schema: schema,
 5140            columns: table => new
 5141            {
 5142                Id = table.Column<string>(maxLength: 450, nullable: false),
 5143                TenantId = table.Column<string>(maxLength: 450, nullable: false),
 5144                TaskId = table.Column<string>(maxLength: 450, nullable: false),
 5145                OperationId = table.Column<string>(maxLength: 450, nullable: false),
 5146                Kind = table.Column<string>(maxLength: 64, nullable: false),
 5147                ExpectedRevision = table.Column<int>(nullable: false),
 5148                RequestHash = table.Column<string>(maxLength: 128, nullable: false),
 5149                Status = table.Column<string>(maxLength: 32, nullable: false),
 5150                Attempts = table.Column<int>(nullable: false),
 5151                SafeResultJson = table.Column<string>(nullable: true),
 5152                ProtectedPayloadJson = table.Column<string>(nullable: true),
 5153                ActionKey = table.Column<string>(maxLength: 200, nullable: true),
 5154                ErrorCode = table.Column<string>(maxLength: 200, nullable: true),
 5155                CreatedAt = table.Column<DateTimeOffset>(nullable: false),
 5156                UpdatedAt = table.Column<DateTimeOffset>(nullable: false),
 5157                CompletedAt = table.Column<DateTimeOffset>(nullable: true)
 5158            },
 10159            constraints: table => table.PrimaryKey("PK_UserTaskOperations", x => x.Id));
 160
 5161        migrationBuilder.CreateTable(name: "UserTaskInvitations", schema: schema,
 5162            columns: table => new
 5163            {
 5164                Id = table.Column<string>(maxLength: 450, nullable: false),
 5165                TenantId = table.Column<string>(maxLength: 450, nullable: false),
 5166                TaskId = table.Column<string>(maxLength: 450, nullable: false),
 5167                SiblingGroupId = table.Column<string>(maxLength: 450, nullable: true),
 5168                RecipientJson = table.Column<string>(nullable: true),
 5169                TokenHash = table.Column<string>(maxLength: 256, nullable: false),
 5170                VerifierProvider = table.Column<string>(maxLength: 200, nullable: false),
 5171                AllowedActionsJson = table.Column<string>(nullable: false),
 5172                ChallengeJson = table.Column<string>(nullable: true),
 5173                Status = table.Column<string>(maxLength: 32, nullable: false),
 5174                IssuedAt = table.Column<DateTimeOffset>(nullable: false),
 5175                ExpiresAt = table.Column<DateTimeOffset>(nullable: false),
 5176                VerifiedAt = table.Column<DateTimeOffset>(nullable: true),
 5177                ConsumedAt = table.Column<DateTimeOffset>(nullable: true),
 5178                RevokedAt = table.Column<DateTimeOffset>(nullable: true)
 5179            },
 10180            constraints: table => table.PrimaryKey("PK_UserTaskInvitations", x => x.Id));
 181
 5182        migrationBuilder.CreateTable(name: "UserTaskInvitationDeliveries", schema: schema,
 5183            columns: table => new
 5184            {
 5185                Id = table.Column<string>(maxLength: 450, nullable: false),
 5186                TenantId = table.Column<string>(maxLength: 450, nullable: false),
 5187                TaskId = table.Column<string>(maxLength: 450, nullable: false),
 5188                InvitationId = table.Column<string>(maxLength: 450, nullable: false),
 5189                DispatcherProvider = table.Column<string>(maxLength: 200, nullable: false),
 5190                EncryptedToken = table.Column<string>(nullable: false),
 5191                DeliveryMetadataJson = table.Column<string>(nullable: true),
 5192                Status = table.Column<string>(maxLength: 32, nullable: false),
 5193                Attempts = table.Column<int>(nullable: false),
 5194                AvailableAt = table.Column<DateTimeOffset>(nullable: false),
 5195                ExpiresAt = table.Column<DateTimeOffset>(nullable: false),
 5196                LastErrorCode = table.Column<string>(maxLength: 128, nullable: true),
 5197                CreatedAt = table.Column<DateTimeOffset>(nullable: false),
 5198                DeliveredAt = table.Column<DateTimeOffset>(nullable: true)
 5199            },
 10200            constraints: table => table.PrimaryKey("PK_UserTaskInvitationDeliveries", x => x.Id));
 201
 5202        migrationBuilder.CreateTable(name: "UserTaskGuestSessions", schema: schema,
 5203            columns: table => new
 5204            {
 5205                Id = table.Column<string>(maxLength: 450, nullable: false),
 5206                TenantId = table.Column<string>(maxLength: 450, nullable: false),
 5207                TaskId = table.Column<string>(maxLength: 450, nullable: false),
 5208                InvitationId = table.Column<string>(maxLength: 450, nullable: false),
 5209                SessionTokenHash = table.Column<string>(maxLength: 256, nullable: false),
 5210                GuestParticipantJson = table.Column<string>(nullable: false),
 5211                CapabilitiesJson = table.Column<string>(nullable: false),
 5212                IssuedAt = table.Column<DateTimeOffset>(nullable: false),
 5213                ExpiresAt = table.Column<DateTimeOffset>(nullable: false),
 5214                RevokedAt = table.Column<DateTimeOffset>(nullable: true)
 5215            },
 10216            constraints: table => table.PrimaryKey("PK_UserTaskGuestSessions", x => x.Id));
 217
 5218        migrationBuilder.CreateIndex(name: "IX_UserTasks_Tenant_MaterializationKey", table: "UserTasks", columns: ["Tena
 5219        migrationBuilder.CreateIndex(name: "IX_UserTasks_Tenant_BookmarkId", table: "UserTasks", columns: ["TenantId", "
 5220        migrationBuilder.CreateIndex(name: "IX_UserTasks_Tenant_Status", table: "UserTasks", columns: ["TenantId", "Stat
 5221        migrationBuilder.CreateIndex(name: "IX_UserTasks_Tenant_Assignee", table: "UserTasks", columns: ["TenantId", "As
 5222        migrationBuilder.CreateIndex(name: "IX_UserTasks_Tenant_Priority", table: "UserTasks", columns: ["TenantId", "Pr
 5223        migrationBuilder.CreateIndex(name: "IX_UserTasks_Tenant_DueAt", table: "UserTasks", columns: ["TenantId", "DueAt
 5224        migrationBuilder.CreateIndex(name: "IX_UserTasks_Tenant_WorkflowDefinition", table: "UserTasks", columns: ["Tena
 5225        migrationBuilder.CreateIndex(name: "IX_UserTasks_Tenant_WorkflowInstance", table: "UserTasks", columns: ["Tenant
 5226        migrationBuilder.CreateIndex(name: "IX_UserTasks_Tenant_ActivityInstance", table: "UserTasks", columns: ["Tenant
 5227        migrationBuilder.CreateIndex(name: "IX_UserTasks_Tenant_CreatedAt", table: "UserTasks", columns: ["TenantId", "C
 5228        migrationBuilder.CreateIndex(name: "IX_UserTasks_Tenant_CompletedAt", table: "UserTasks", columns: ["TenantId", 
 5229        migrationBuilder.CreateIndex(name: "IX_UserTaskCandidates_Tenant_Task_Participant", table: "UserTaskCandidates",
 5230        migrationBuilder.CreateIndex(name: "IX_UserTaskCandidates_Tenant_Participant", table: "UserTaskCandidates", colu
 5231        migrationBuilder.CreateIndex(name: "IX_UserTaskCandidates_Tenant_Task", table: "UserTaskCandidates", columns: ["
 5232        migrationBuilder.CreateIndex(name: "IX_UserTaskCandidates_Tenant_Task_ParticipantKey", table: "UserTaskCandidate
 5233        migrationBuilder.CreateIndex(name: "IX_UserTaskSnapshotMembers_Tenant_Task_Participant", table: "UserTaskSnapsho
 5234        migrationBuilder.CreateIndex(name: "IX_UserTaskSnapshotMembers_Tenant_Task_ParticipantKey", table: "UserTaskSnap
 5235        migrationBuilder.CreateIndex(name: "IX_UserTaskExclusions_Tenant_Task_Participant", table: "UserTaskExclusions",
 5236        migrationBuilder.CreateIndex(name: "IX_UserTaskExclusions_Tenant_Task_ParticipantKey", table: "UserTaskExclusion
 237        // Not unique: audit is append-only and several entries may share a revision, because an audited read
 238        // (a masked-field reveal) records without consuming the aggregate's concurrency token.
 5239        migrationBuilder.CreateIndex(name: "IX_UserTaskEvents_Task_Revision", table: "UserTaskEvents", columns: ["TaskId
 5240        migrationBuilder.CreateIndex(name: "IX_UserTaskEvents_Tenant_Task_OccurredAt", table: "UserTaskEvents", columns:
 5241        migrationBuilder.CreateIndex(name: "IX_UserTaskOperations_Tenant_Task_Operation", table: "UserTaskOperations", c
 5242        migrationBuilder.CreateIndex(name: "IX_UserTaskOperations_Tenant_Status_UpdatedAt", table: "UserTaskOperations",
 5243        migrationBuilder.CreateIndex(name: "IX_UserTaskInvitations_TokenHash", table: "UserTaskInvitations", column: "To
 5244        migrationBuilder.CreateIndex(name: "IX_UserTaskInvitations_Tenant_Task_Status", table: "UserTaskInvitations", co
 5245        migrationBuilder.CreateIndex(name: "IX_UserTaskInvitations_Tenant_Status_ExpiresAt", table: "UserTaskInvitations
 5246        migrationBuilder.CreateIndex(name: "IX_UserTaskInvitationDeliveries_Tenant_Status_AvailableAt", table: "UserTask
 5247        migrationBuilder.CreateIndex(name: "IX_UserTaskInvitationDeliveries_Tenant_Invitation", table: "UserTaskInvitati
 5248        migrationBuilder.CreateIndex(name: "IX_UserTaskGuestSessions_SessionTokenHash", table: "UserTaskGuestSessions", 
 5249        migrationBuilder.CreateIndex(name: "IX_UserTaskGuestSessions_Tenant_Task_ExpiresAt", table: "UserTaskGuestSessio
 5250        migrationBuilder.CreateIndex(name: "IX_UserTaskGuestSessions_Tenant_Invitation", table: "UserTaskGuestSessions",
 5251    }
 252
 253    public static void Down(MigrationBuilder migrationBuilder, string schema)
 254    {
 0255        migrationBuilder.DropTable("UserTaskGuestSessions", schema);
 0256        migrationBuilder.DropTable("UserTaskInvitationDeliveries", schema);
 0257        migrationBuilder.DropTable("UserTaskInvitations", schema);
 0258        migrationBuilder.DropTable("UserTaskOperations", schema);
 0259        migrationBuilder.DropTable("UserTaskEvents", schema);
 0260        migrationBuilder.DropTable("UserTaskExclusions", schema);
 0261        migrationBuilder.DropTable("UserTaskSnapshotMembers", schema);
 0262        migrationBuilder.DropTable("UserTaskCandidates", schema);
 0263        migrationBuilder.DropTable("UserTasks", schema);
 0264    }
 265}