| | | 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="AsiBackboneAuditLedgerRecordEntity" />. |
| | | 9 | | /// </summary> |
| | | 10 | | public sealed class AsiBackboneAuditLedgerRecordEntityConfiguration |
| | | 11 | | : IEntityTypeConfiguration<AsiBackboneAuditLedgerRecordEntity> |
| | | 12 | | { |
| | | 13 | | private const int IdentifierMaxLength = 128; |
| | | 14 | | private const int SchemaVersionMaxLength = 64; |
| | | 15 | | private const int DisplayNameMaxLength = 256; |
| | | 16 | | private const int OperationNameMaxLength = 256; |
| | | 17 | | private const int OutcomeMaxLength = 128; |
| | | 18 | | private const int ActorTypeMaxLength = 64; |
| | | 19 | | private const int CorrelationMaxLength = 128; |
| | | 20 | | private const int PolicyVersionMaxLength = 128; |
| | | 21 | | private const int PolicyScopeMaxLength = 256; |
| | | 22 | | private const int StatusMaxLength = 128; |
| | | 23 | | private const int ProviderMaxLength = 128; |
| | | 24 | | private const int StageMaxLength = 128; |
| | | 25 | | private const int HashMaxLength = 512; |
| | | 26 | | private const int SignatureKeyIdMaxLength = 128; |
| | | 27 | | private const int SignatureAlgorithmMaxLength = 128; |
| | | 28 | | private const int ConcurrencyStampMaxLength = 64; |
| | | 29 | | |
| | | 30 | | /// <inheritdoc /> |
| | | 31 | | public void Configure(EntityTypeBuilder<AsiBackboneAuditLedgerRecordEntity> builder) |
| | | 32 | | { |
| | 22 | 33 | | ArgumentNullException.ThrowIfNull(builder); |
| | | 34 | | |
| | 22 | 35 | | _ = builder.ToTable("AsiBackboneAuditLedgerRecords"); |
| | | 36 | | |
| | 22 | 37 | | _ = builder.HasKey(record => record.Id); |
| | | 38 | | |
| | 22 | 39 | | _ = builder.Property(record => record.Id) |
| | 22 | 40 | | .ValueGeneratedNever(); |
| | | 41 | | |
| | 22 | 42 | | _ = builder.Property(record => record.ConcurrencyStamp) |
| | 22 | 43 | | .IsRequired() |
| | 22 | 44 | | .HasMaxLength(ConcurrencyStampMaxLength) |
| | 22 | 45 | | .IsConcurrencyToken(); |
| | | 46 | | |
| | 22 | 47 | | _ = builder.Property(record => record.RecordId) |
| | 22 | 48 | | .IsRequired() |
| | 22 | 49 | | .HasMaxLength(IdentifierMaxLength); |
| | | 50 | | |
| | 22 | 51 | | _ = builder.Property(record => record.SchemaVersion) |
| | 22 | 52 | | .IsRequired() |
| | 22 | 53 | | .HasMaxLength(SchemaVersionMaxLength); |
| | | 54 | | |
| | 22 | 55 | | _ = builder.Property(record => record.EventId) |
| | 22 | 56 | | .IsRequired() |
| | 22 | 57 | | .HasMaxLength(IdentifierMaxLength); |
| | | 58 | | |
| | 22 | 59 | | _ = builder.Property(record => record.AuditResidueId) |
| | 22 | 60 | | .HasMaxLength(IdentifierMaxLength); |
| | | 61 | | |
| | 22 | 62 | | _ = builder.Property(record => record.OccurredUtc) |
| | 22 | 63 | | .IsRequired(); |
| | | 64 | | |
| | 22 | 65 | | _ = builder.Property(record => record.RecordedUtc) |
| | 22 | 66 | | .IsRequired(); |
| | | 67 | | |
| | 22 | 68 | | _ = builder.Property(record => record.ActorId) |
| | 22 | 69 | | .IsRequired() |
| | 22 | 70 | | .HasMaxLength(IdentifierMaxLength); |
| | | 71 | | |
| | 22 | 72 | | _ = builder.Property(record => record.ActorType) |
| | 22 | 73 | | .HasConversion<string>() |
| | 22 | 74 | | .IsRequired() |
| | 22 | 75 | | .HasMaxLength(ActorTypeMaxLength); |
| | | 76 | | |
| | 22 | 77 | | _ = builder.Property(record => record.ActorDisplayName) |
| | 22 | 78 | | .HasMaxLength(DisplayNameMaxLength); |
| | | 79 | | |
| | 22 | 80 | | _ = builder.Property(record => record.OperationName) |
| | 22 | 81 | | .IsRequired() |
| | 22 | 82 | | .HasMaxLength(OperationNameMaxLength); |
| | | 83 | | |
| | 22 | 84 | | _ = builder.Property(record => record.Outcome) |
| | 22 | 85 | | .IsRequired() |
| | 22 | 86 | | .HasMaxLength(OutcomeMaxLength); |
| | | 87 | | |
| | 22 | 88 | | _ = builder.Property(record => record.ReasonCodesJson) |
| | 22 | 89 | | .IsRequired(); |
| | | 90 | | |
| | 22 | 91 | | _ = builder.Property(record => record.CorrelationId) |
| | 22 | 92 | | .HasMaxLength(CorrelationMaxLength); |
| | | 93 | | |
| | 22 | 94 | | _ = builder.Property(record => record.TraceId) |
| | 22 | 95 | | .HasMaxLength(CorrelationMaxLength); |
| | | 96 | | |
| | 22 | 97 | | _ = builder.Property(record => record.SpanId) |
| | 22 | 98 | | .HasMaxLength(CorrelationMaxLength); |
| | | 99 | | |
| | 22 | 100 | | _ = builder.Property(record => record.ParentSpanId) |
| | 22 | 101 | | .HasMaxLength(CorrelationMaxLength); |
| | | 102 | | |
| | 22 | 103 | | _ = builder.Property(record => record.ConstraintSetHash) |
| | 22 | 104 | | .HasMaxLength(HashMaxLength); |
| | | 105 | | |
| | 22 | 106 | | _ = builder.Property(record => record.PolicyScope) |
| | 22 | 107 | | .HasMaxLength(PolicyScopeMaxLength); |
| | | 108 | | |
| | 22 | 109 | | _ = builder.Property(record => record.TenantHash) |
| | 22 | 110 | | .HasMaxLength(HashMaxLength); |
| | | 111 | | |
| | 22 | 112 | | _ = builder.Property(record => record.OrganizationHash) |
| | 22 | 113 | | .HasMaxLength(HashMaxLength); |
| | | 114 | | |
| | 22 | 115 | | _ = builder.Property(record => record.EmitterStatus) |
| | 22 | 116 | | .HasMaxLength(StatusMaxLength); |
| | | 117 | | |
| | 22 | 118 | | _ = builder.Property(record => record.EmitterProvider) |
| | 22 | 119 | | .HasMaxLength(ProviderMaxLength); |
| | | 120 | | |
| | 22 | 121 | | _ = builder.Property(record => record.GatewayExecutionId) |
| | 22 | 122 | | .HasMaxLength(IdentifierMaxLength); |
| | | 123 | | |
| | 22 | 124 | | _ = builder.Property(record => record.DecisionStage) |
| | 22 | 125 | | .HasMaxLength(StageMaxLength); |
| | | 126 | | |
| | 22 | 127 | | _ = builder.Property(record => record.PolicyVersion) |
| | 22 | 128 | | .HasMaxLength(PolicyVersionMaxLength); |
| | | 129 | | |
| | 22 | 130 | | _ = builder.Property(record => record.PolicyHash) |
| | 22 | 131 | | .HasMaxLength(HashMaxLength); |
| | | 132 | | |
| | 22 | 133 | | _ = builder.Property(record => record.HandshakeId) |
| | 22 | 134 | | .HasMaxLength(IdentifierMaxLength); |
| | | 135 | | |
| | 22 | 136 | | _ = builder.Property(record => record.AcknowledgmentId) |
| | 22 | 137 | | .HasMaxLength(IdentifierMaxLength); |
| | | 138 | | |
| | 22 | 139 | | _ = builder.Property(record => record.CapabilityTokenId) |
| | 22 | 140 | | .HasMaxLength(IdentifierMaxLength); |
| | | 141 | | |
| | 22 | 142 | | _ = builder.Property(record => record.PreviousRecordHash) |
| | 22 | 143 | | .HasMaxLength(HashMaxLength); |
| | | 144 | | |
| | 22 | 145 | | _ = builder.Property(record => record.RecordHash) |
| | 22 | 146 | | .HasMaxLength(HashMaxLength); |
| | | 147 | | |
| | 22 | 148 | | _ = builder.Property(record => record.SignatureKeyId) |
| | 22 | 149 | | .HasMaxLength(SignatureKeyIdMaxLength); |
| | | 150 | | |
| | 22 | 151 | | _ = builder.Property(record => record.SignatureAlgorithm) |
| | 22 | 152 | | .HasMaxLength(SignatureAlgorithmMaxLength); |
| | | 153 | | |
| | 22 | 154 | | _ = builder.Property(record => record.SignatureValue); |
| | | 155 | | |
| | 22 | 156 | | _ = builder.Property(record => record.MetadataJson) |
| | 22 | 157 | | .IsRequired(); |
| | | 158 | | |
| | 22 | 159 | | _ = builder.HasIndex(record => record.RecordId) |
| | 22 | 160 | | .IsUnique(); |
| | | 161 | | |
| | 22 | 162 | | _ = builder.HasIndex(record => record.SchemaVersion); |
| | | 163 | | |
| | 22 | 164 | | _ = builder.HasIndex(record => record.EventId); |
| | | 165 | | |
| | 22 | 166 | | _ = builder.HasIndex(record => record.AuditResidueId); |
| | | 167 | | |
| | 22 | 168 | | _ = builder.HasIndex(record => record.OccurredUtc); |
| | | 169 | | |
| | 22 | 170 | | _ = builder.HasIndex(record => record.RecordedUtc); |
| | | 171 | | |
| | 22 | 172 | | _ = builder.HasIndex(record => record.ActorId); |
| | | 173 | | |
| | 22 | 174 | | _ = builder.HasIndex(record => record.ActorType); |
| | | 175 | | |
| | 22 | 176 | | _ = builder.HasIndex(record => record.OperationName); |
| | | 177 | | |
| | 22 | 178 | | _ = builder.HasIndex(record => record.Outcome); |
| | | 179 | | |
| | 22 | 180 | | _ = builder.HasIndex(record => record.CorrelationId); |
| | | 181 | | |
| | 22 | 182 | | _ = builder.HasIndex(record => record.TraceId); |
| | | 183 | | |
| | 22 | 184 | | _ = builder.HasIndex(record => record.SpanId); |
| | | 185 | | |
| | 22 | 186 | | _ = builder.HasIndex(record => record.PolicyVersion); |
| | | 187 | | |
| | 22 | 188 | | _ = builder.HasIndex(record => record.PolicyHash); |
| | | 189 | | |
| | 22 | 190 | | _ = builder.HasIndex(record => record.PolicyScope); |
| | | 191 | | |
| | 22 | 192 | | _ = builder.HasIndex(record => record.TenantHash); |
| | | 193 | | |
| | 22 | 194 | | _ = builder.HasIndex(record => record.OrganizationHash); |
| | | 195 | | |
| | 22 | 196 | | _ = builder.HasIndex(record => record.EmitterStatus); |
| | | 197 | | |
| | 22 | 198 | | _ = builder.HasIndex(record => record.EmitterProvider); |
| | | 199 | | |
| | 22 | 200 | | _ = builder.HasIndex(record => record.OutboxSequence); |
| | | 201 | | |
| | 22 | 202 | | _ = builder.HasIndex(record => record.GatewayExecutionId); |
| | | 203 | | |
| | 22 | 204 | | _ = builder.HasIndex(record => record.DecisionStage); |
| | | 205 | | |
| | 22 | 206 | | _ = builder.HasIndex(record => record.HandshakeId); |
| | | 207 | | |
| | 22 | 208 | | _ = builder.HasIndex(record => record.AcknowledgmentId); |
| | | 209 | | |
| | 22 | 210 | | _ = builder.HasIndex(record => record.CapabilityTokenId); |
| | | 211 | | |
| | 22 | 212 | | _ = builder.HasIndex(record => record.RecordHash); |
| | | 213 | | |
| | 22 | 214 | | _ = builder.HasIndex(record => new |
| | 22 | 215 | | { |
| | 22 | 216 | | record.ActorId, |
| | 22 | 217 | | record.RecordedUtc |
| | 22 | 218 | | }); |
| | | 219 | | |
| | 22 | 220 | | _ = builder.HasIndex(record => new |
| | 22 | 221 | | { |
| | 22 | 222 | | record.CorrelationId, |
| | 22 | 223 | | record.RecordedUtc |
| | 22 | 224 | | }); |
| | 22 | 225 | | } |
| | | 226 | | } |