| | | 1 | | using Elsa.Labels.Entities; |
| | | 2 | | using Microsoft.EntityFrameworkCore; |
| | | 3 | | using Microsoft.EntityFrameworkCore.Metadata.Builders; |
| | | 4 | | |
| | | 5 | | namespace Elsa.Persistence.EFCore.Modules.Labels; |
| | | 6 | | |
| | | 7 | | public class Configurations : IEntityTypeConfiguration<Label>, IEntityTypeConfiguration<WorkflowDefinitionLabel> |
| | | 8 | | { |
| | | 9 | | public void Configure(EntityTypeBuilder<Label> builder) |
| | | 10 | | { |
| | 4 | 11 | | builder.Property(x => x.Name).HasMaxLength(Label.NameMaxLength).IsRequired(); |
| | 4 | 12 | | builder.Property(x => x.NormalizedName).HasMaxLength(Label.NameMaxLength).IsRequired(); |
| | | 13 | | |
| | | 14 | | // Uniqueness is per tenant, matching Secrets (and User, Role, Application). |
| | | 15 | | // A global unique index would make the name a shared resource across tenants. |
| | | 16 | | // SQL Server/Oracle still emit a filtered unique index (TenantId IS NOT NULL). |
| | | 17 | | // Default-tenant rows use "" — migrations stamp leftover null TenantId to "" first. |
| | 4 | 18 | | builder.HasIndex(x => new { x.TenantId, x.NormalizedName }) |
| | 4 | 19 | | .HasDatabaseName($"IX_{nameof(Label)}_{nameof(Label.TenantId)}_{nameof(Label.NormalizedName)}") |
| | 4 | 20 | | .IsUnique(); |
| | 4 | 21 | | } |
| | | 22 | | |
| | | 23 | | public void Configure(EntityTypeBuilder<WorkflowDefinitionLabel> builder) |
| | | 24 | | { |
| | 2 | 25 | | builder.HasIndex(x => x.WorkflowDefinitionId).HasDatabaseName($"{nameof(WorkflowDefinitionLabel)}_{nameof(Workfl |
| | 2 | 26 | | builder.HasIndex(x => x.WorkflowDefinitionVersionId).HasDatabaseName($"{nameof(WorkflowDefinitionLabel)}_{nameof |
| | 2 | 27 | | builder.HasIndex(x => x.LabelId).HasDatabaseName($"{nameof(WorkflowDefinitionLabel)}_{nameof(WorkflowDefinitionL |
| | 2 | 28 | | builder.HasIndex(x => x.TenantId).HasDatabaseName($"{nameof(WorkflowDefinitionLabel)}_{nameof(WorkflowDefinition |
| | 2 | 29 | | } |
| | | 30 | | } |