| | | 1 | | using System.Linq.Expressions; |
| | | 2 | | using Elsa.Workflows.Management.Entities; |
| | | 3 | | using Microsoft.EntityFrameworkCore; |
| | | 4 | | using Microsoft.EntityFrameworkCore.Metadata.Builders; |
| | | 5 | | |
| | | 6 | | namespace Elsa.Persistence.EFCore.Modules.Management; |
| | | 7 | | |
| | | 8 | | internal class Configurations : IEntityTypeConfiguration<WorkflowDefinition>, IEntityTypeConfiguration<WorkflowInstance> |
| | | 9 | | { |
| | 1 | 10 | | private static Expression<Func<Version?, string?>> VersionToStringConverter => v => v != null ? v.ToString() : null; |
| | 1 | 11 | | private static Expression<Func<string?, Version?>> StringToVersionConverter => v => v != null ? Version.Parse(v) : n |
| | | 12 | | |
| | | 13 | | public void Configure(EntityTypeBuilder<WorkflowDefinition> builder) |
| | | 14 | | { |
| | 1 | 15 | | builder.Ignore(x => x.Variables); |
| | 1 | 16 | | builder.Ignore(x => x.Inputs); |
| | 1 | 17 | | builder.Ignore(x => x.Outputs); |
| | 1 | 18 | | builder.Ignore(x => x.Outcomes); |
| | 1 | 19 | | builder.Ignore(x => x.CustomProperties); |
| | 1 | 20 | | builder.Ignore(x => x.Options); |
| | 1 | 21 | | builder.Property<string>("Data"); |
| | 1 | 22 | | builder.Property<bool?>("UsableAsActivity"); |
| | 1 | 23 | | builder.Property(x => x.ToolVersion).HasConversion(VersionToStringConverter, StringToVersionConverter); |
| | 1 | 24 | | builder.HasIndex(x => new {x.DefinitionId, x.Version}).HasDatabaseName($"IX_{nameof(WorkflowDefinition)}_{nameof |
| | 1 | 25 | | builder.HasIndex(x => x.Version).HasDatabaseName($"IX_{nameof(WorkflowDefinition)}_{nameof(WorkflowDefinition.Ve |
| | 1 | 26 | | builder.HasIndex(x => x.Name).HasDatabaseName($"IX_{nameof(WorkflowDefinition)}_{nameof(WorkflowDefinition.Name) |
| | 1 | 27 | | builder.HasIndex(x => x.IsLatest).HasDatabaseName($"IX_{nameof(WorkflowDefinition)}_{nameof(WorkflowDefinition.I |
| | 1 | 28 | | builder.HasIndex(x => x.IsPublished).HasDatabaseName($"IX_{nameof(WorkflowDefinition)}_{nameof(WorkflowDefinitio |
| | 1 | 29 | | builder.HasIndex(x => x.IsSystem).HasDatabaseName($"IX_{nameof(WorkflowDefinition)}_{nameof(WorkflowDefinition.I |
| | 1 | 30 | | builder.HasIndex("UsableAsActivity").HasDatabaseName($"IX_{nameof(WorkflowDefinition)}_UsableAsActivity"); |
| | 1 | 31 | | builder.HasIndex(x => x.TenantId).HasDatabaseName($"IX_{nameof(WorkflowDefinition)}_{nameof(WorkflowDefinition.T |
| | 1 | 32 | | } |
| | | 33 | | |
| | | 34 | | public void Configure(EntityTypeBuilder<WorkflowInstance> builder) |
| | | 35 | | { |
| | 1 | 36 | | builder.Ignore(x => x.WorkflowState); |
| | 1 | 37 | | builder.Property<string>("Data"); |
| | 1 | 38 | | builder.Property<string>("DataCompressionAlgorithm"); |
| | 1 | 39 | | builder.Property(x => x.Status).HasConversion<string>(); |
| | 1 | 40 | | builder.Property(x => x.SubStatus).HasConversion<string>(); |
| | 1 | 41 | | builder.HasIndex(x => new { x.Status, x.SubStatus, x.DefinitionId, x.Version }).HasDatabaseName($"IX_{nameof(Wor |
| | 1 | 42 | | builder.HasIndex(x => new { x.Status, x.SubStatus }).HasDatabaseName($"IX_{nameof(WorkflowInstance)}_{nameof(Wor |
| | 1 | 43 | | builder.HasIndex(x => new { x.Status, x.DefinitionId }).HasDatabaseName($"IX_{nameof(WorkflowInstance)}_{nameof( |
| | 1 | 44 | | builder.HasIndex(x => new { x.SubStatus, x.DefinitionId }).HasDatabaseName($"IX_{nameof(WorkflowInstance)}_{name |
| | 1 | 45 | | builder.HasIndex(x => new { x.IsExecuting }).HasDatabaseName($"IX_{nameof(WorkflowInstance)}_{nameof(WorkflowIns |
| | 1 | 46 | | builder.HasIndex(x => x.DefinitionId).HasDatabaseName($"IX_{nameof(WorkflowInstance)}_{nameof(WorkflowInstance.D |
| | 1 | 47 | | builder.HasIndex(x => x.Status).HasDatabaseName($"IX_{nameof(WorkflowInstance)}_{nameof(WorkflowInstance.Status) |
| | 1 | 48 | | builder.HasIndex(x => x.SubStatus).HasDatabaseName($"IX_{nameof(WorkflowInstance)}_{nameof(WorkflowInstance.SubS |
| | 1 | 49 | | builder.HasIndex(x => x.CorrelationId).HasDatabaseName($"IX_{nameof(WorkflowInstance)}_{nameof(WorkflowInstance. |
| | 1 | 50 | | builder.HasIndex(x => x.Name).HasDatabaseName($"IX_{nameof(WorkflowInstance)}_{nameof(WorkflowInstance.Name)}"); |
| | 1 | 51 | | builder.HasIndex(x => x.CreatedAt).HasDatabaseName($"IX_{nameof(WorkflowInstance)}_{nameof(WorkflowInstance.Crea |
| | 1 | 52 | | builder.HasIndex(x => x.UpdatedAt).HasDatabaseName($"IX_{nameof(WorkflowInstance)}_{nameof(WorkflowInstance.Upda |
| | 1 | 53 | | builder.HasIndex(x => x.FinishedAt).HasDatabaseName($"IX_{nameof(WorkflowInstance)}_{nameof(WorkflowInstance.Fin |
| | 1 | 54 | | builder.HasIndex(x => x.IsSystem).HasDatabaseName($"IX_{nameof(WorkflowInstance)}_{nameof(WorkflowInstance.IsSys |
| | 1 | 55 | | builder.HasIndex(x => x.TenantId).HasDatabaseName($"IX_{nameof(WorkflowInstance)}_{nameof(WorkflowInstance.Tenan |
| | 1 | 56 | | } |
| | | 57 | | } |