| | | 1 | | using AsiBackbone.EntityFrameworkCore.Persistence; |
| | | 2 | | using Microsoft.EntityFrameworkCore; |
| | | 3 | | using Microsoft.EntityFrameworkCore.Metadata.Builders; |
| | | 4 | | |
| | | 5 | | namespace AsiBackbone.EntityFrameworkCore.Configurations; |
| | | 6 | | |
| | | 7 | | /// <summary> |
| | | 8 | | /// Configures the Entity Framework Core persistence mapping for <see cref="AsiBackboneGovernanceOutboxEntryEntity" />. |
| | | 9 | | /// </summary> |
| | | 10 | | public sealed class AsiBackboneGovernanceOutboxEntryEntityConfiguration |
| | | 11 | | : IEntityTypeConfiguration<AsiBackboneGovernanceOutboxEntryEntity> |
| | | 12 | | { |
| | | 13 | | private const int IdentifierMaxLength = 128; |
| | | 14 | | private const int SchemaVersionMaxLength = 64; |
| | | 15 | | private const int StatusMaxLength = 128; |
| | | 16 | | private const int ProviderMaxLength = 128; |
| | | 17 | | private const int ErrorCodeMaxLength = 128; |
| | | 18 | | private const int ProviderErrorCodeMaxLength = 128; |
| | | 19 | | private const int StageMaxLength = 128; |
| | | 20 | | private const int OperationNameMaxLength = 256; |
| | | 21 | | private const int OutcomeMaxLength = 128; |
| | | 22 | | private const int PolicyVersionMaxLength = 128; |
| | | 23 | | private const int HashMaxLength = 512; |
| | | 24 | | private const int ContentTypeMaxLength = 256; |
| | | 25 | | private const int PayloadTypeMaxLength = 128; |
| | | 26 | | private const int ConcurrencyStampMaxLength = 64; |
| | | 27 | | |
| | | 28 | | /// <inheritdoc /> |
| | | 29 | | public void Configure(EntityTypeBuilder<AsiBackboneGovernanceOutboxEntryEntity> builder) |
| | | 30 | | { |
| | 22 | 31 | | ArgumentNullException.ThrowIfNull(builder); |
| | | 32 | | |
| | 22 | 33 | | _ = builder.ToTable("AsiBackboneGovernanceOutboxEntries"); |
| | | 34 | | |
| | 22 | 35 | | _ = builder.HasKey(outboxEntry => outboxEntry.Id); |
| | | 36 | | |
| | 22 | 37 | | _ = builder.Property(outboxEntry => outboxEntry.Id) |
| | 22 | 38 | | .ValueGeneratedNever(); |
| | | 39 | | |
| | 22 | 40 | | _ = builder.Property(outboxEntry => outboxEntry.ConcurrencyStamp) |
| | 22 | 41 | | .IsRequired() |
| | 22 | 42 | | .HasMaxLength(ConcurrencyStampMaxLength) |
| | 22 | 43 | | .IsConcurrencyToken(); |
| | | 44 | | |
| | 22 | 45 | | _ = builder.Property(outboxEntry => outboxEntry.OutboxEntryId) |
| | 22 | 46 | | .IsRequired() |
| | 22 | 47 | | .HasMaxLength(IdentifierMaxLength); |
| | | 48 | | |
| | 22 | 49 | | _ = builder.Property(outboxEntry => outboxEntry.Status) |
| | 22 | 50 | | .HasConversion<string>() |
| | 22 | 51 | | .IsRequired() |
| | 22 | 52 | | .HasMaxLength(StatusMaxLength); |
| | | 53 | | |
| | 22 | 54 | | _ = builder.Property(outboxEntry => outboxEntry.CreatedUtc) |
| | 22 | 55 | | .IsRequired(); |
| | | 56 | | |
| | 22 | 57 | | _ = builder.Property(outboxEntry => outboxEntry.UpdatedUtc) |
| | 22 | 58 | | .IsRequired(); |
| | | 59 | | |
| | 22 | 60 | | _ = builder.Property(outboxEntry => outboxEntry.RetryCount) |
| | 22 | 61 | | .IsRequired(); |
| | | 62 | | |
| | 22 | 63 | | _ = builder.Property(outboxEntry => outboxEntry.MaxRetryCount) |
| | 22 | 64 | | .IsRequired(); |
| | | 65 | | |
| | 22 | 66 | | _ = builder.Property(outboxEntry => outboxEntry.ProviderName) |
| | 22 | 67 | | .HasMaxLength(ProviderMaxLength); |
| | | 68 | | |
| | 22 | 69 | | _ = builder.Property(outboxEntry => outboxEntry.ProviderRecordId) |
| | 22 | 70 | | .HasMaxLength(IdentifierMaxLength); |
| | | 71 | | |
| | 22 | 72 | | _ = builder.Property(outboxEntry => outboxEntry.LastErrorCode) |
| | 22 | 73 | | .HasMaxLength(ErrorCodeMaxLength); |
| | | 74 | | |
| | 22 | 75 | | _ = builder.Property(outboxEntry => outboxEntry.LastErrorProviderName) |
| | 22 | 76 | | .HasMaxLength(ProviderMaxLength); |
| | | 77 | | |
| | 22 | 78 | | _ = builder.Property(outboxEntry => outboxEntry.LastErrorProviderErrorCode) |
| | 22 | 79 | | .HasMaxLength(ProviderErrorCodeMaxLength); |
| | | 80 | | |
| | 22 | 81 | | _ = builder.Property(outboxEntry => outboxEntry.MetadataJson) |
| | 22 | 82 | | .IsRequired(); |
| | | 83 | | |
| | 22 | 84 | | _ = builder.Property(outboxEntry => outboxEntry.EnvelopeId) |
| | 22 | 85 | | .IsRequired() |
| | 22 | 86 | | .HasMaxLength(IdentifierMaxLength); |
| | | 87 | | |
| | 22 | 88 | | _ = builder.Property(outboxEntry => outboxEntry.EnvelopeSchemaVersion) |
| | 22 | 89 | | .IsRequired() |
| | 22 | 90 | | .HasMaxLength(SchemaVersionMaxLength); |
| | | 91 | | |
| | 22 | 92 | | _ = builder.Property(outboxEntry => outboxEntry.EnvelopeEventType) |
| | 22 | 93 | | .HasConversion<string>() |
| | 22 | 94 | | .IsRequired() |
| | 22 | 95 | | .HasMaxLength(StatusMaxLength); |
| | | 96 | | |
| | 22 | 97 | | _ = builder.Property(outboxEntry => outboxEntry.EnvelopeEventId) |
| | 22 | 98 | | .HasMaxLength(IdentifierMaxLength); |
| | | 99 | | |
| | 22 | 100 | | _ = builder.Property(outboxEntry => outboxEntry.EnvelopeOccurredUtc) |
| | 22 | 101 | | .IsRequired(); |
| | | 102 | | |
| | 22 | 103 | | _ = builder.Property(outboxEntry => outboxEntry.EnvelopeCreatedUtc) |
| | 22 | 104 | | .IsRequired(); |
| | | 105 | | |
| | 22 | 106 | | _ = builder.Property(outboxEntry => outboxEntry.EnvelopeCorrelationId) |
| | 22 | 107 | | .HasMaxLength(IdentifierMaxLength); |
| | | 108 | | |
| | 22 | 109 | | _ = builder.Property(outboxEntry => outboxEntry.EnvelopeAuditResidueId) |
| | 22 | 110 | | .HasMaxLength(IdentifierMaxLength); |
| | | 111 | | |
| | 22 | 112 | | _ = builder.Property(outboxEntry => outboxEntry.EnvelopeLifecycleStage) |
| | 22 | 113 | | .HasConversion<string>() |
| | 22 | 114 | | .HasMaxLength(StageMaxLength); |
| | | 115 | | |
| | 22 | 116 | | _ = builder.Property(outboxEntry => outboxEntry.EnvelopePolicyVersion) |
| | 22 | 117 | | .HasMaxLength(PolicyVersionMaxLength); |
| | | 118 | | |
| | 22 | 119 | | _ = builder.Property(outboxEntry => outboxEntry.EnvelopePolicyHash) |
| | 22 | 120 | | .HasMaxLength(HashMaxLength); |
| | | 121 | | |
| | 22 | 122 | | _ = builder.Property(outboxEntry => outboxEntry.EnvelopeTraceId) |
| | 22 | 123 | | .HasMaxLength(IdentifierMaxLength); |
| | | 124 | | |
| | 22 | 125 | | _ = builder.Property(outboxEntry => outboxEntry.EnvelopeSpanId) |
| | 22 | 126 | | .HasMaxLength(IdentifierMaxLength); |
| | | 127 | | |
| | 22 | 128 | | _ = builder.Property(outboxEntry => outboxEntry.EnvelopeParentSpanId) |
| | 22 | 129 | | .HasMaxLength(IdentifierMaxLength); |
| | | 130 | | |
| | 22 | 131 | | _ = builder.Property(outboxEntry => outboxEntry.EnvelopeOperationName) |
| | 22 | 132 | | .HasMaxLength(OperationNameMaxLength); |
| | | 133 | | |
| | 22 | 134 | | _ = builder.Property(outboxEntry => outboxEntry.EnvelopeOutcome) |
| | 22 | 135 | | .HasMaxLength(OutcomeMaxLength); |
| | | 136 | | |
| | 22 | 137 | | _ = builder.Property(outboxEntry => outboxEntry.EnvelopeActorId) |
| | 22 | 138 | | .HasMaxLength(IdentifierMaxLength); |
| | | 139 | | |
| | 22 | 140 | | _ = builder.Property(outboxEntry => outboxEntry.EnvelopeEmitterStatus) |
| | 22 | 141 | | .HasMaxLength(StatusMaxLength); |
| | | 142 | | |
| | 22 | 143 | | _ = builder.Property(outboxEntry => outboxEntry.EnvelopeEmitterProvider) |
| | 22 | 144 | | .HasMaxLength(ProviderMaxLength); |
| | | 145 | | |
| | 22 | 146 | | _ = builder.Property(outboxEntry => outboxEntry.EnvelopeGatewayExecutionId) |
| | 22 | 147 | | .HasMaxLength(IdentifierMaxLength); |
| | | 148 | | |
| | 22 | 149 | | _ = builder.Property(outboxEntry => outboxEntry.EnvelopeDecisionStage) |
| | 22 | 150 | | .HasMaxLength(StageMaxLength); |
| | | 151 | | |
| | 22 | 152 | | _ = builder.Property(outboxEntry => outboxEntry.EnvelopeMetadataJson) |
| | 22 | 153 | | .IsRequired(); |
| | | 154 | | |
| | 22 | 155 | | _ = builder.Property(outboxEntry => outboxEntry.EnvelopePayloadType) |
| | 22 | 156 | | .HasMaxLength(PayloadTypeMaxLength); |
| | | 157 | | |
| | 22 | 158 | | _ = builder.Property(outboxEntry => outboxEntry.EnvelopePayloadSchemaVersion) |
| | 22 | 159 | | .HasMaxLength(SchemaVersionMaxLength); |
| | | 160 | | |
| | 22 | 161 | | _ = builder.Property(outboxEntry => outboxEntry.EnvelopePayloadContentType) |
| | 22 | 162 | | .HasMaxLength(ContentTypeMaxLength); |
| | | 163 | | |
| | 22 | 164 | | _ = builder.Property(outboxEntry => outboxEntry.EnvelopePayloadContentHash) |
| | 22 | 165 | | .HasMaxLength(HashMaxLength); |
| | | 166 | | |
| | 22 | 167 | | _ = builder.Property(outboxEntry => outboxEntry.EnvelopePayloadMetadataJson) |
| | 22 | 168 | | .IsRequired(); |
| | | 169 | | |
| | 22 | 170 | | _ = builder.HasIndex(outboxEntry => outboxEntry.OutboxEntryId) |
| | 22 | 171 | | .IsUnique(); |
| | | 172 | | |
| | 22 | 173 | | _ = builder.HasIndex(outboxEntry => outboxEntry.Status); |
| | | 174 | | |
| | 22 | 175 | | _ = builder.HasIndex(outboxEntry => outboxEntry.NextRetryUtc); |
| | | 176 | | |
| | 22 | 177 | | _ = builder.HasIndex(outboxEntry => outboxEntry.CreatedUtc); |
| | | 178 | | |
| | 22 | 179 | | _ = builder.HasIndex(outboxEntry => outboxEntry.UpdatedUtc); |
| | | 180 | | |
| | 22 | 181 | | _ = builder.HasIndex(outboxEntry => outboxEntry.DeliveredUtc); |
| | | 182 | | |
| | 22 | 183 | | _ = builder.HasIndex(outboxEntry => outboxEntry.ProviderName); |
| | | 184 | | |
| | 22 | 185 | | _ = builder.HasIndex(outboxEntry => outboxEntry.ProviderRecordId); |
| | | 186 | | |
| | 22 | 187 | | _ = builder.HasIndex(outboxEntry => outboxEntry.LastErrorCode); |
| | | 188 | | |
| | 22 | 189 | | _ = builder.HasIndex(outboxEntry => outboxEntry.EnvelopeId); |
| | | 190 | | |
| | 22 | 191 | | _ = builder.HasIndex(outboxEntry => outboxEntry.EnvelopeEventId); |
| | | 192 | | |
| | 22 | 193 | | _ = builder.HasIndex(outboxEntry => outboxEntry.EnvelopeCorrelationId); |
| | | 194 | | |
| | 22 | 195 | | _ = builder.HasIndex(outboxEntry => outboxEntry.EnvelopeAuditResidueId); |
| | | 196 | | |
| | 22 | 197 | | _ = builder.HasIndex(outboxEntry => outboxEntry.EnvelopePolicyVersion); |
| | | 198 | | |
| | 22 | 199 | | _ = builder.HasIndex(outboxEntry => outboxEntry.EnvelopePolicyHash); |
| | | 200 | | |
| | 22 | 201 | | _ = builder.HasIndex(outboxEntry => outboxEntry.EnvelopeTraceId); |
| | | 202 | | |
| | 22 | 203 | | _ = builder.HasIndex(outboxEntry => outboxEntry.EnvelopeOutboxSequence); |
| | | 204 | | |
| | 22 | 205 | | _ = builder.HasIndex(outboxEntry => new |
| | 22 | 206 | | { |
| | 22 | 207 | | outboxEntry.Status, |
| | 22 | 208 | | outboxEntry.NextRetryUtc, |
| | 22 | 209 | | outboxEntry.UpdatedUtc |
| | 22 | 210 | | }); |
| | | 211 | | |
| | 22 | 212 | | _ = builder.HasIndex(outboxEntry => new |
| | 22 | 213 | | { |
| | 22 | 214 | | outboxEntry.Status, |
| | 22 | 215 | | outboxEntry.CreatedUtc |
| | 22 | 216 | | }); |
| | | 217 | | |
| | 22 | 218 | | _ = builder.HasIndex(outboxEntry => new |
| | 22 | 219 | | { |
| | 22 | 220 | | outboxEntry.EnvelopeCorrelationId, |
| | 22 | 221 | | outboxEntry.CreatedUtc |
| | 22 | 222 | | }); |
| | | 223 | | |
| | 22 | 224 | | _ = builder.HasIndex(outboxEntry => new |
| | 22 | 225 | | { |
| | 22 | 226 | | outboxEntry.EnvelopeAuditResidueId, |
| | 22 | 227 | | outboxEntry.CreatedUtc |
| | 22 | 228 | | }); |
| | 22 | 229 | | } |
| | | 230 | | } |