| | | 1 | | using Elsa.KeyValues.Entities; |
| | | 2 | | using Elsa.Workflows.Runtime.Entities; |
| | | 3 | | using Microsoft.EntityFrameworkCore; |
| | | 4 | | using Microsoft.EntityFrameworkCore.Metadata.Builders; |
| | | 5 | | |
| | | 6 | | namespace Elsa.Persistence.EFCore.Modules.Runtime; |
| | | 7 | | |
| | | 8 | | /// <summary> |
| | | 9 | | /// EF Core configuration for various sets of <see cref="DbContext"/>. |
| | | 10 | | /// </summary> |
| | | 11 | | public class Configurations : |
| | | 12 | | IEntityTypeConfiguration<StoredTrigger>, |
| | | 13 | | IEntityTypeConfiguration<WorkflowExecutionLogRecord>, |
| | | 14 | | IEntityTypeConfiguration<ActivityExecutionRecord>, |
| | | 15 | | IEntityTypeConfiguration<StoredBookmark>, |
| | | 16 | | IEntityTypeConfiguration<BookmarkQueueItem>, |
| | | 17 | | IEntityTypeConfiguration<SerializedKeyValuePair>, |
| | | 18 | | IEntityTypeConfiguration<WorkflowInboxMessage> |
| | | 19 | | { |
| | | 20 | | /// <inheritdoc /> |
| | | 21 | | public void Configure(EntityTypeBuilder<ActivityExecutionRecord> builder) |
| | | 22 | | { |
| | 1 | 23 | | builder.Ignore(x => x.ActivityState); |
| | 1 | 24 | | builder.Ignore(x => x.Exception); |
| | 1 | 25 | | builder.Ignore(x => x.Payload); |
| | 1 | 26 | | builder.Ignore(x => x.Outputs); |
| | 1 | 27 | | builder.Ignore(x => x.Metadata); |
| | 1 | 28 | | builder.Ignore(x => x.Properties); |
| | 1 | 29 | | builder.Property<string>("SerializedActivityState"); |
| | 1 | 30 | | builder.Property<string>("SerializedActivityStateCompressionAlgorithm"); |
| | 1 | 31 | | builder.Property<string>("SerializedException"); |
| | 1 | 32 | | builder.Property<string>("SerializedPayload"); |
| | 1 | 33 | | builder.Property<string>("SerializedOutputs"); |
| | 1 | 34 | | builder.Property<string>("SerializedProperties"); |
| | 1 | 35 | | builder.Property<string>("SerializedMetadata"); |
| | 1 | 36 | | builder.Property(x => x.Status).HasConversion<string>(); |
| | 1 | 37 | | builder.HasIndex(x => x.WorkflowInstanceId).HasDatabaseName($"IX_{nameof(ActivityExecutionRecord)}_{nameof(Activ |
| | 1 | 38 | | builder.HasIndex(x => x.ActivityId).HasDatabaseName($"IX_{nameof(ActivityExecutionRecord)}_{nameof(ActivityExecu |
| | 1 | 39 | | builder.HasIndex(x => x.ActivityNodeId).HasDatabaseName($"IX_{nameof(ActivityExecutionRecord)}_{nameof(ActivityE |
| | 1 | 40 | | builder.HasIndex(x => x.ActivityType).HasDatabaseName($"IX_{nameof(ActivityExecutionRecord)}_{nameof(ActivityExe |
| | 1 | 41 | | builder.HasIndex(x => x.ActivityTypeVersion).HasDatabaseName($"IX_{nameof(ActivityExecutionRecord)}_{nameof(Acti |
| | 1 | 42 | | builder.HasIndex(x => new |
| | 1 | 43 | | { |
| | 1 | 44 | | x.ActivityType, |
| | 1 | 45 | | x.ActivityTypeVersion |
| | 1 | 46 | | }).HasDatabaseName($"IX_{nameof(ActivityExecutionRecord)}_{nameof(ActivityExecutionRecord.ActivityType)}_{nameof |
| | 1 | 47 | | builder.HasIndex(x => x.ActivityName).HasDatabaseName($"IX_{nameof(ActivityExecutionRecord)}_{nameof(ActivityExe |
| | 1 | 48 | | builder.HasIndex(x => x.StartedAt).HasDatabaseName($"IX_{nameof(ActivityExecutionRecord)}_{nameof(ActivityExecut |
| | 1 | 49 | | builder.HasIndex(x => x.HasBookmarks).HasDatabaseName($"IX_{nameof(ActivityExecutionRecord)}_{nameof(ActivityExe |
| | 1 | 50 | | builder.HasIndex(x => x.Status).HasDatabaseName($"IX_{nameof(ActivityExecutionRecord)}_{nameof(ActivityExecution |
| | 1 | 51 | | builder.HasIndex(x => x.CompletedAt).HasDatabaseName($"IX_{nameof(ActivityExecutionRecord)}_{nameof(ActivityExec |
| | 1 | 52 | | builder.HasIndex(x => x.TenantId).HasDatabaseName($"IX_{nameof(ActivityExecutionRecord)}_{nameof(ActivityExecuti |
| | 1 | 53 | | } |
| | | 54 | | |
| | | 55 | | public void Configure(EntityTypeBuilder<BookmarkQueueItem> builder) |
| | | 56 | | { |
| | 1 | 57 | | builder.Ignore(x => x.Options); |
| | 1 | 58 | | builder.Property<string>("SerializedOptions"); |
| | 1 | 59 | | builder.HasIndex(x => x.StimulusHash, $"IX_{nameof(BookmarkQueueItem)}_{nameof(BookmarkQueueItem.StimulusHash)}" |
| | 1 | 60 | | builder.HasIndex(x => x.WorkflowInstanceId, $"IX_{nameof(BookmarkQueueItem)}_{nameof(BookmarkQueueItem.WorkflowI |
| | 1 | 61 | | builder.HasIndex(x => x.CorrelationId, $"IX_{nameof(BookmarkQueueItem)}_{nameof(BookmarkQueueItem.CorrelationId) |
| | 1 | 62 | | builder.HasIndex(x => x.BookmarkId, $"IX_{nameof(BookmarkQueueItem)}_{nameof(BookmarkQueueItem.BookmarkId)}"); |
| | 1 | 63 | | builder.HasIndex(x => x.ActivityInstanceId, $"IX_{nameof(BookmarkQueueItem)}_{nameof(BookmarkQueueItem.ActivityI |
| | 1 | 64 | | builder.HasIndex(x => x.ActivityTypeName, $"IX_{nameof(BookmarkQueueItem)}_{nameof(BookmarkQueueItem.ActivityTyp |
| | 1 | 65 | | builder.HasIndex(x => x.CreatedAt, $"IX_{nameof(BookmarkQueueItem)}_{nameof(BookmarkQueueItem.CreatedAt)}"); |
| | 1 | 66 | | builder.HasIndex(x => x.TenantId, $"IX_{nameof(BookmarkQueueItem)}_{nameof(BookmarkQueueItem.TenantId)}"); |
| | 1 | 67 | | } |
| | | 68 | | |
| | | 69 | | /// <inheritdoc /> |
| | | 70 | | public void Configure(EntityTypeBuilder<SerializedKeyValuePair> builder) |
| | | 71 | | { |
| | 1 | 72 | | builder.HasKey(x => x.Id); |
| | 1 | 73 | | builder.Ignore(x => x.Key); |
| | 1 | 74 | | builder.HasIndex(x => x.TenantId, $"IX_{nameof(SerializedKeyValuePair)}_{nameof(SerializedKeyValuePair.TenantId) |
| | 1 | 75 | | } |
| | | 76 | | |
| | | 77 | | /// <inheritdoc /> |
| | | 78 | | public void Configure(EntityTypeBuilder<StoredBookmark> builder) |
| | | 79 | | { |
| | 1 | 80 | | builder.Ignore(x => x.Payload); |
| | 1 | 81 | | builder.Ignore(x => x.Metadata); |
| | 1 | 82 | | builder.HasKey(b => b.Id); |
| | 1 | 83 | | builder.Property<string>("SerializedPayload"); |
| | 1 | 84 | | builder.Property<string>("SerializedMetadata"); |
| | 1 | 85 | | builder.HasIndex(x => x.ActivityTypeName, $"IX_{nameof(StoredBookmark)}_{nameof(StoredBookmark.ActivityTypeName) |
| | 1 | 86 | | builder.HasIndex(x => x.Name, $"IX_{nameof(StoredBookmark)}_{nameof(StoredBookmark.Name)}"); |
| | 1 | 87 | | builder.HasIndex(x => x.Hash, $"IX_{nameof(StoredBookmark)}_{nameof(StoredBookmark.Hash)}"); |
| | 1 | 88 | | builder.HasIndex(x => x.WorkflowInstanceId, $"IX_{nameof(StoredBookmark)}_{nameof(StoredBookmark.WorkflowInstanc |
| | 1 | 89 | | builder.HasIndex(x => x.ActivityInstanceId, $"IX_{nameof(StoredBookmark)}_{nameof(StoredBookmark.ActivityInstanc |
| | 1 | 90 | | builder.HasIndex(x => x.CreatedAt, $"IX_{nameof(StoredBookmark)}_{nameof(StoredBookmark.CreatedAt)}"); |
| | 1 | 91 | | builder.HasIndex(x => new |
| | 1 | 92 | | { |
| | 1 | 93 | | x.ActivityTypeName, |
| | 1 | 94 | | x.Hash |
| | 1 | 95 | | }, $"IX_{nameof(StoredBookmark)}_{nameof(StoredBookmark.ActivityTypeName)}_{nameof(StoredBookmark.Hash)}"); |
| | 1 | 96 | | builder.HasIndex(x => new |
| | 1 | 97 | | { |
| | 1 | 98 | | x.ActivityTypeName, |
| | 1 | 99 | | x.Hash, |
| | 1 | 100 | | x.WorkflowInstanceId |
| | 1 | 101 | | }, $"IX_{nameof(StoredBookmark)}_{nameof(StoredBookmark.ActivityTypeName)}_{nameof(StoredBookmark.Hash)}_{na |
| | 1 | 102 | | builder.HasIndex(x => new |
| | 1 | 103 | | { |
| | 1 | 104 | | ActivityTypeName = x.Name, |
| | 1 | 105 | | x.Hash |
| | 1 | 106 | | }, $"IX_{nameof(StoredBookmark)}_{nameof(StoredBookmark.Name)}_{nameof(StoredBookmark.Hash)}"); |
| | 1 | 107 | | builder.HasIndex(x => new |
| | 1 | 108 | | { |
| | 1 | 109 | | ActivityTypeName = x.Name, |
| | 1 | 110 | | x.Hash, |
| | 1 | 111 | | x.WorkflowInstanceId |
| | 1 | 112 | | }, $"IX_{nameof(StoredBookmark)}_{nameof(StoredBookmark.Name)}_{nameof(StoredBookmark.Hash)}_{nameof(StoredB |
| | 1 | 113 | | builder.HasIndex(x => x.TenantId, $"IX_{nameof(StoredBookmark)}_{nameof(StoredBookmark.TenantId)}"); |
| | 1 | 114 | | } |
| | | 115 | | |
| | | 116 | | /// <inheritdoc /> |
| | | 117 | | public void Configure(EntityTypeBuilder<StoredTrigger> builder) |
| | | 118 | | { |
| | 1 | 119 | | builder.Ignore(x => x.Payload); |
| | 1 | 120 | | builder.Property<string>("SerializedPayload"); |
| | 1 | 121 | | builder.HasIndex(x => x.WorkflowDefinitionId).HasDatabaseName($"IX_{nameof(StoredTrigger)}_{nameof(StoredTrigger |
| | 1 | 122 | | builder.HasIndex(x => x.WorkflowDefinitionVersionId).HasDatabaseName($"IX_{nameof(StoredTrigger)}_{nameof(Stored |
| | 1 | 123 | | builder.HasIndex(x => x.Name).HasDatabaseName($"IX_{nameof(StoredTrigger)}_{nameof(StoredTrigger.Name)}"); |
| | 1 | 124 | | builder.HasIndex(x => x.Hash).HasDatabaseName($"IX_{nameof(StoredTrigger)}_{nameof(StoredTrigger.Hash)}"); |
| | 1 | 125 | | builder.HasIndex(x => x.TenantId).HasDatabaseName($"IX_{nameof(StoredTrigger)}_{nameof(StoredTrigger.TenantId)}" |
| | 1 | 126 | | } |
| | | 127 | | |
| | | 128 | | /// <inheritdoc /> |
| | | 129 | | public void Configure(EntityTypeBuilder<WorkflowExecutionLogRecord> builder) |
| | | 130 | | { |
| | 1 | 131 | | builder.Ignore(x => x.ActivityState); |
| | 1 | 132 | | builder.Ignore(x => x.Payload); |
| | 1 | 133 | | builder.Property<string>("SerializedActivityState"); |
| | 1 | 134 | | builder.Property<string>("SerializedPayload"); |
| | 1 | 135 | | builder.HasIndex(x => x.Timestamp).HasDatabaseName($"IX_{nameof(WorkflowExecutionLogRecord)}_{nameof(WorkflowExe |
| | 1 | 136 | | builder.HasIndex(x => x.Sequence).HasDatabaseName($"IX_{nameof(WorkflowExecutionLogRecord)}_{nameof(WorkflowExec |
| | 1 | 137 | | builder.HasIndex(x => new |
| | 1 | 138 | | { |
| | 1 | 139 | | x.Timestamp, |
| | 1 | 140 | | x.Sequence |
| | 1 | 141 | | }).HasDatabaseName($"IX_{nameof(WorkflowExecutionLogRecord)}_{nameof(WorkflowExecutionLogRecord.Timestamp)}_{nam |
| | 1 | 142 | | builder.HasIndex(x => x.ActivityInstanceId).HasDatabaseName($"IX_{nameof(WorkflowExecutionLogRecord)}_{nameof(Wo |
| | 1 | 143 | | builder.HasIndex(x => x.ParentActivityInstanceId).HasDatabaseName($"IX_{nameof(WorkflowExecutionLogRecord)}_{nam |
| | 1 | 144 | | builder.HasIndex(x => x.ActivityId).HasDatabaseName($"IX_{nameof(WorkflowExecutionLogRecord)}_{nameof(WorkflowEx |
| | 1 | 145 | | builder.HasIndex(x => x.ActivityNodeId).HasDatabaseName($"IX_{nameof(WorkflowExecutionLogRecord)}_{nameof(Workfl |
| | 1 | 146 | | builder.HasIndex(x => x.ActivityType).HasDatabaseName($"IX_{nameof(WorkflowExecutionLogRecord)}_{nameof(Workflow |
| | 1 | 147 | | builder.HasIndex(x => x.ActivityTypeVersion).HasDatabaseName($"IX_{nameof(WorkflowExecutionLogRecord)}_{nameof(W |
| | 1 | 148 | | builder.HasIndex(x => new |
| | 1 | 149 | | { |
| | 1 | 150 | | x.ActivityType, |
| | 1 | 151 | | x.ActivityTypeVersion |
| | 1 | 152 | | }).HasDatabaseName($"IX_{nameof(WorkflowExecutionLogRecord)}_{nameof(WorkflowExecutionLogRecord.ActivityType)}_{ |
| | 1 | 153 | | builder.HasIndex(x => x.ActivityName).HasDatabaseName($"IX_{nameof(WorkflowExecutionLogRecord)}_{nameof(Workflow |
| | 1 | 154 | | builder.HasIndex(x => x.EventName).HasDatabaseName($"IX_{nameof(WorkflowExecutionLogRecord)}_{nameof(WorkflowExe |
| | 1 | 155 | | builder.HasIndex(x => x.WorkflowDefinitionId).HasDatabaseName($"IX_{nameof(WorkflowExecutionLogRecord)}_{nameof( |
| | 1 | 156 | | builder.HasIndex(x => x.WorkflowDefinitionVersionId).HasDatabaseName($"IX_{nameof(WorkflowExecutionLogRecord)}_{ |
| | 1 | 157 | | builder.HasIndex(x => x.WorkflowInstanceId).HasDatabaseName($"IX_{nameof(WorkflowExecutionLogRecord)}_{nameof(Wo |
| | 1 | 158 | | builder.HasIndex(x => x.WorkflowVersion).HasDatabaseName($"IX_{nameof(WorkflowExecutionLogRecord)}_{nameof(Workf |
| | 1 | 159 | | builder.HasIndex(x => x.TenantId).HasDatabaseName($"IX_{nameof(WorkflowExecutionLogRecord)}_{nameof(WorkflowExec |
| | 1 | 160 | | } |
| | | 161 | | |
| | | 162 | | public void Configure(EntityTypeBuilder<WorkflowInboxMessage> builder) |
| | | 163 | | { |
| | 1 | 164 | | builder.Ignore(x => x.Input); |
| | 1 | 165 | | builder.Ignore(x => x.BookmarkPayload); |
| | 1 | 166 | | builder.Property<string>("SerializedInput"); |
| | 1 | 167 | | builder.Property<string>("SerializedBookmarkPayload"); |
| | 1 | 168 | | builder.HasIndex(x => x.ActivityTypeName, $"IX_{nameof(WorkflowInboxMessage)}_{nameof(WorkflowInboxMessage.Activ |
| | 1 | 169 | | builder.HasIndex(x => x.Hash, $"IX_{nameof(WorkflowInboxMessage)}_{nameof(WorkflowInboxMessage.Hash)}"); |
| | 1 | 170 | | builder.HasIndex(x => x.WorkflowInstanceId, $"IX_{nameof(WorkflowInboxMessage)}_{nameof(WorkflowInboxMessage.Wor |
| | 1 | 171 | | builder.HasIndex(x => x.CorrelationId, $"IX_{nameof(WorkflowInboxMessage)}_{nameof(WorkflowInboxMessage.Correlat |
| | 1 | 172 | | builder.HasIndex(x => x.ActivityInstanceId, $"IX_{nameof(WorkflowInboxMessage)}_{nameof(WorkflowInboxMessage.Act |
| | 1 | 173 | | builder.HasIndex(x => x.CreatedAt, $"IX_{nameof(WorkflowInboxMessage)}_{nameof(WorkflowInboxMessage.CreatedAt)}" |
| | 1 | 174 | | builder.HasIndex(x => x.ExpiresAt, $"IX_{nameof(WorkflowInboxMessage)}_{nameof(WorkflowInboxMessage.ExpiresAt)}" |
| | 1 | 175 | | } |
| | | 176 | | } |