< Summary

Information
Class: Elsa.UserTasks.Persistence.EFCore.UserTaskEntityConfiguration
Assembly: Elsa.UserTasks.Persistence.EFCore
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.UserTasks.Persistence.EFCore/UserTaskEntityConfiguration.cs
Line coverage
100%
Covered lines: 175
Uncovered lines: 0
Coverable lines: 175
Total lines: 192
Line coverage: 100%
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
Configure(...)100%11100%

File(s)

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

#LineLine coverage
 1using Microsoft.EntityFrameworkCore;
 2
 3namespace Elsa.UserTasks.Persistence.EFCore;
 4
 5internal static class UserTaskEntityConfiguration
 6{
 7    public static void Configure(ModelBuilder modelBuilder)
 8    {
 29        modelBuilder.Entity<UserTaskRecord>(entity =>
 210        {
 211            entity.ToTable("UserTasks");
 212            entity.HasKey(x => x.Id);
 213            entity.Property(x => x.TenantId).HasMaxLength(450).IsRequired();
 214            entity.Property(x => x.WorkflowDefinitionId).HasMaxLength(450).IsRequired();
 215            entity.Property(x => x.WorkflowDefinitionName).HasMaxLength(500);
 216            entity.Property(x => x.WorkflowInstanceId).HasMaxLength(450).IsRequired();
 217            entity.Property(x => x.WorkflowInstanceReference).HasMaxLength(500);
 218            entity.Property(x => x.ActivityInstanceId).HasMaxLength(450).IsRequired();
 219            entity.Property(x => x.BookmarkId).HasMaxLength(450).IsRequired();
 220            entity.Property(x => x.MaterializationKey).HasMaxLength(900).IsRequired();
 221            entity.Property(x => x.Title).HasMaxLength(500).IsRequired();
 222            entity.Property(x => x.Summary).HasMaxLength(4000);
 223            entity.Property(x => x.Reference).HasMaxLength(500);
 224            entity.Property(x => x.TaskType).HasMaxLength(200);
 225            entity.Property(x => x.TagsJson).IsRequired();
 226            entity.Property(x => x.RequesterProvider).HasMaxLength(200);
 227            entity.Property(x => x.RequesterType).HasMaxLength(64);
 228            entity.Property(x => x.RequesterId).HasMaxLength(450);
 229            entity.Property(x => x.RequesterDisplayName).HasMaxLength(500);
 230            entity.Property(x => x.Status).HasConversion<string>().HasMaxLength(32).IsRequired();
 231            entity.Property(x => x.MembershipResolutionMode).HasConversion<string>().HasMaxLength(32);
 232            entity.Property(x => x.AssigneeProvider).HasMaxLength(200);
 233            entity.Property(x => x.AssigneeType).HasMaxLength(64);
 234            entity.Property(x => x.AssigneeId).HasMaxLength(450);
 235            entity.Property(x => x.AssigneeDisplayName).HasMaxLength(500);
 236            entity.Property(x => x.InstructionsJson).IsRequired();
 237            entity.Property(x => x.TaskDataJson).IsRequired();
 238            entity.Property(x => x.InvitationDefinitionsJson).IsRequired();
 239            entity.Property(x => x.HealthIssuesJson).IsRequired();
 240            entity.Property(x => x.HealthSeverity).HasConversion<string>().HasMaxLength(32);
 241            entity.Property(x => x.HealthCode).HasMaxLength(200);
 242            entity.Property(x => x.HealthMessage).HasMaxLength(4000);
 243            entity.Property(x => x.Revision).IsConcurrencyToken().IsRequired();
 244            entity.HasIndex(x => new { x.TenantId, x.MaterializationKey }).IsUnique();
 245            entity.HasIndex(x => new { x.TenantId, x.BookmarkId }).IsUnique();
 246            entity.HasIndex(x => new { x.TenantId, x.Status });
 247            entity.HasIndex(x => new { x.TenantId, x.AssigneeProvider, x.AssigneeType, x.AssigneeId });
 248            entity.HasIndex(x => new { x.TenantId, x.Priority });
 249            entity.HasIndex(x => new { x.TenantId, x.DueAt });
 250            entity.HasIndex(x => new { x.TenantId, x.WorkflowDefinitionId });
 251            entity.HasIndex(x => new { x.TenantId, x.WorkflowInstanceId });
 252            entity.HasIndex(x => new { x.TenantId, x.ActivityInstanceId });
 253            entity.HasIndex(x => new { x.TenantId, x.CreatedAt });
 254            entity.HasIndex(x => new { x.TenantId, x.CompletedAt });
 455        });
 56
 257        modelBuilder.Entity<UserTaskCandidateRecord>(entity =>
 258        {
 259            entity.ToTable("UserTaskCandidates");
 260            entity.HasKey(x => x.Id);
 261            entity.Property(x => x.TenantId).HasMaxLength(450).IsRequired();
 262            entity.Property(x => x.TaskId).HasMaxLength(450).IsRequired();
 263            entity.Property(x => x.Provider).HasMaxLength(200).IsRequired();
 264            entity.Property(x => x.ParticipantKey).HasMaxLength(800).IsRequired();
 265            entity.Property(x => x.ParticipantType).HasConversion<string>().HasMaxLength(32).IsRequired();
 266            entity.Property(x => x.ParticipantId).HasMaxLength(450).IsRequired();
 267            entity.Property(x => x.DisplayName).HasMaxLength(500);
 268            entity.Property(x => x.Source).HasConversion<string>().HasMaxLength(32).IsRequired();
 269            entity.Property(x => x.SourceGroupProvider).HasMaxLength(200);
 270            entity.Property(x => x.SourceGroupId).HasMaxLength(450);
 271            entity.HasIndex(x => new { x.TenantId, x.TaskId, x.Provider, x.ParticipantType, x.ParticipantId, x.Source })
 272            entity.HasIndex(x => new { x.TenantId, x.Provider, x.ParticipantType, x.ParticipantId });
 273            entity.HasIndex(x => new { x.TenantId, x.TaskId, x.ParticipantKey });
 274            entity.HasIndex(x => new { x.TenantId, x.TaskId });
 475        });
 76
 277        modelBuilder.Entity<UserTaskSnapshotMemberRecord>(entity =>
 278        {
 279            entity.ToTable("UserTaskSnapshotMembers");
 280            entity.HasKey(x => x.Id);
 281            entity.Property(x => x.TenantId).HasMaxLength(450).IsRequired();
 282            entity.Property(x => x.TaskId).HasMaxLength(450).IsRequired();
 283            entity.Property(x => x.Provider).HasMaxLength(200).IsRequired();
 284            entity.Property(x => x.ParticipantKey).HasMaxLength(800).IsRequired();
 285            entity.Property(x => x.ParticipantType).HasConversion<string>().HasMaxLength(32).IsRequired();
 286            entity.Property(x => x.ParticipantId).HasMaxLength(450).IsRequired();
 287            entity.Property(x => x.SourceGroupProvider).HasMaxLength(200);
 288            entity.Property(x => x.SourceGroupId).HasMaxLength(450);
 289            entity.HasIndex(x => new { x.TenantId, x.TaskId, x.Provider, x.ParticipantType, x.ParticipantId }).IsUnique(
 290            entity.HasIndex(x => new { x.TenantId, x.Provider, x.ParticipantType, x.ParticipantId });
 291            entity.HasIndex(x => new { x.TenantId, x.TaskId, x.ParticipantKey });
 492        });
 93
 294        modelBuilder.Entity<UserTaskExclusionRecord>(entity =>
 295        {
 296            entity.ToTable("UserTaskExclusions");
 297            entity.HasKey(x => x.Id);
 298            entity.Property(x => x.TenantId).HasMaxLength(450).IsRequired();
 299            entity.Property(x => x.TaskId).HasMaxLength(450).IsRequired();
 2100            entity.Property(x => x.Provider).HasMaxLength(200).IsRequired();
 2101            entity.Property(x => x.ParticipantKey).HasMaxLength(800).IsRequired();
 2102            entity.Property(x => x.ParticipantType).HasConversion<string>().HasMaxLength(32).IsRequired();
 2103            entity.Property(x => x.ParticipantId).HasMaxLength(450).IsRequired();
 2104            entity.HasIndex(x => new { x.TenantId, x.TaskId, x.Provider, x.ParticipantType, x.ParticipantId }).IsUnique(
 2105            entity.HasIndex(x => new { x.TenantId, x.Provider, x.ParticipantType, x.ParticipantId });
 2106            entity.HasIndex(x => new { x.TenantId, x.TaskId, x.ParticipantKey });
 4107        });
 108
 2109        modelBuilder.Entity<UserTaskEventRecord>(entity =>
 2110        {
 2111            entity.ToTable("UserTaskEvents");
 2112            entity.HasKey(x => x.Id);
 2113            entity.Property(x => x.TenantId).HasMaxLength(450).IsRequired();
 2114            entity.Property(x => x.TaskId).HasMaxLength(450).IsRequired();
 2115            entity.Property(x => x.EventType).HasMaxLength(64).IsRequired();
 2116            entity.Property(x => x.OperationId).HasMaxLength(450);
 2117            entity.Property(x => x.ActorProvider).HasMaxLength(200);
 2118            entity.Property(x => x.ActorType).HasMaxLength(64);
 2119            entity.Property(x => x.ActorId).HasMaxLength(450);
 2120            entity.Property(x => x.Reason).HasMaxLength(4000);
 2121            entity.Property(x => x.MetadataJson).IsRequired();
 2122            // Audit is append-only and several entries may share a revision (an audited read does not
 2123            // consume the concurrency token), so this is a lookup index rather than a uniqueness constraint.
 2124            entity.HasIndex(x => new { x.TaskId, x.Revision });
 2125            entity.HasIndex(x => new { x.TenantId, x.TaskId, x.OccurredAt });
 4126        });
 127
 2128        modelBuilder.Entity<UserTaskOperationRecord>(entity =>
 2129        {
 2130            entity.ToTable("UserTaskOperations");
 2131            entity.HasKey(x => x.Id);
 2132            entity.Property(x => x.TenantId).HasMaxLength(450).IsRequired();
 2133            entity.Property(x => x.TaskId).HasMaxLength(450).IsRequired();
 2134            entity.Property(x => x.OperationId).HasMaxLength(450).IsRequired();
 2135            entity.Property(x => x.Kind).HasMaxLength(64).IsRequired();
 2136            entity.Property(x => x.RequestHash).HasMaxLength(128).IsRequired();
 2137            entity.Property(x => x.Status).HasConversion<string>().HasMaxLength(32).IsRequired();
 2138            entity.Property(x => x.ActionKey).HasMaxLength(200);
 2139            entity.Property(x => x.ErrorCode).HasMaxLength(200);
 2140            entity.HasIndex(x => new { x.TenantId, x.TaskId, x.OperationId }).IsUnique();
 2141            entity.HasIndex(x => new { x.TenantId, x.Status, x.UpdatedAt });
 4142        });
 143
 2144        modelBuilder.Entity<UserTaskInvitationRecord>(entity =>
 2145        {
 2146            entity.ToTable("UserTaskInvitations");
 2147            entity.HasKey(x => x.Id);
 2148            entity.Property(x => x.TenantId).HasMaxLength(450).IsRequired();
 2149            entity.Property(x => x.TaskId).HasMaxLength(450).IsRequired();
 2150            entity.Property(x => x.SiblingGroupId).HasMaxLength(450);
 2151            entity.Property(x => x.TokenHash).HasMaxLength(256).IsRequired();
 2152            entity.Property(x => x.VerifierProvider).HasMaxLength(200).IsRequired();
 2153            entity.Property(x => x.AllowedActionsJson).IsRequired();
 2154            entity.Property(x => x.Status).HasConversion<string>().HasMaxLength(32).IsRequired();
 2155            entity.HasIndex(x => x.TokenHash).IsUnique();
 2156            entity.HasIndex(x => new { x.TenantId, x.TaskId, x.Status });
 2157            entity.HasIndex(x => new { x.TenantId, x.Status, x.ExpiresAt });
 4158        });
 159
 2160        modelBuilder.Entity<UserTaskInvitationDeliveryRecord>(entity =>
 2161        {
 2162            entity.ToTable("UserTaskInvitationDeliveries");
 2163            entity.HasKey(x => x.Id);
 2164            entity.Property(x => x.TenantId).HasMaxLength(450).IsRequired();
 2165            entity.Property(x => x.TaskId).HasMaxLength(450).IsRequired();
 2166            entity.Property(x => x.InvitationId).HasMaxLength(450).IsRequired();
 2167            entity.Property(x => x.DispatcherProvider).HasMaxLength(200).IsRequired();
 2168            entity.Property(x => x.EncryptedToken).IsRequired();
 2169            entity.Property(x => x.Status).HasConversion<string>().HasMaxLength(32).IsRequired();
 2170            entity.Property(x => x.LastErrorCode).HasMaxLength(128);
 2171            entity.HasIndex(x => new { x.TenantId, x.Status, x.AvailableAt });
 2172            entity.HasIndex(x => new { x.TenantId, x.InvitationId }).IsUnique();
 4173        });
 174
 2175        modelBuilder.Entity<UserTaskGuestSessionRecord>(entity =>
 2176        {
 2177            entity.ToTable("UserTaskGuestSessions");
 2178            entity.HasKey(x => x.Id);
 2179            entity.Property(x => x.TenantId).HasMaxLength(450).IsRequired();
 2180            entity.Property(x => x.TaskId).HasMaxLength(450).IsRequired();
 2181            entity.Property(x => x.InvitationId).HasMaxLength(450).IsRequired();
 2182            entity.Property(x => x.SessionTokenHash).HasMaxLength(256).IsRequired();
 2183            entity.Property(x => x.GuestParticipantJson).IsRequired();
 2184            entity.Property(x => x.CapabilitiesJson).IsRequired();
 2185            entity.HasIndex(x => x.SessionTokenHash).IsUnique();
 2186            entity.HasIndex(x => new { x.TenantId, x.TaskId, x.ExpiresAt });
 2187            // Invitation-scoped revocation filters on this pair; without it every revoke scans the
 2188            // tenant partition, which keeps growing because expired session rows are retained.
 2189            entity.HasIndex(x => new { x.TenantId, x.InvitationId });
 4190        });
 2191    }
 192}