Skip to content

Commit

Permalink
--wip-- [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
oskogstad committed Feb 26, 2025
1 parent 0755721 commit 9708879
Show file tree
Hide file tree
Showing 9 changed files with 2,325 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Digdir.Domain.Dialogporten.Domain.Common;
using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities;
using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using static Digdir.Domain.Dialogporten.Domain.Common.Constants;

namespace Digdir.Domain.Dialogporten.Infrastructure.Persistence.Configurations.Dialogs;

Expand All @@ -11,7 +11,7 @@ public void Configure(EntityTypeBuilder<DialogEntity> builder)
{
builder.ToTable("Dialog");
builder.Property(x => x.ServiceResource)
.HasMaxLength(Constants.DefaultMaxStringLength);
.HasMaxLength(DefaultMaxStringLength);
builder.HasIndex(x => x.CreatedAt);
builder.HasIndex(x => x.DueAt);
builder.HasIndex(x => x.UpdatedAt);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Digdir.Domain.Dialogporten.Domain.Common;
using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using static Digdir.Domain.Dialogporten.Domain.Common.Constants;

namespace Digdir.Domain.Dialogporten.Infrastructure.Persistence.Configurations.Dialogs;

Expand All @@ -12,6 +12,10 @@ public void Configure(EntityTypeBuilder<DialogSearchTag> builder)
builder.HasIndex(x => new { x.DialogId, x.Value })
.IsUnique();
builder.Property(x => x.Value)
.HasMaxLength(Constants.MaxSearchTagLength);
.HasMaxLength(MaxSearchTagLength);

builder.HasIndex(x => x.Value)
.HasMethod(Constants.Gin)
.HasOperators(Constants.GinTrgmOps);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,10 @@ public void Configure(EntityTypeBuilder<Localization> builder)
builder.HasKey(x => new { x.LocalizationSetId, CultureCode = x.LanguageCode });
builder.Property(x => x.LanguageCode).HasMaxLength(15);
builder.Property(x => x.Value).HasMaxLength(4095);

builder.HasIndex(x => x.Value)
.HasMethod("gin")
.HasOperators("gin_trgm_ops");

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Digdir.Domain.Dialogporten.Infrastructure.Persistence;

internal static class Constants
{
internal const string Gin = "gin";
internal const string GinTrgmOps = "gin_trgm_ops";
internal const string PostrgreSqlTrigram = "pg_trgm";
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ public async Task<List<Guid>> GetExistingIds<TEntity>(

protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder)
{
configurationBuilder.Properties<string>(x => x.HaveMaxLength(Constants.DefaultMaxStringLength));
configurationBuilder.Properties<Uri>(x => x.HaveMaxLength(Constants.DefaultMaxUriLength));
configurationBuilder.Properties<string>(x => x.HaveMaxLength(Domain.Common.Constants.DefaultMaxStringLength));
configurationBuilder.Properties<Uri>(x => x.HaveMaxLength(Domain.Common.Constants.DefaultMaxUriLength));
configurationBuilder.Properties<DateTimeOffset>().HaveConversion<DateTimeOffsetConverter>();
configurationBuilder.Properties<TimeSpan>().HaveConversion<TimeSpanToStringConverter>();
}
Expand All @@ -113,6 +113,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)


modelBuilder
.HasPostgresExtension(Constants.PostrgreSqlTrigram)
.RemovePluralizingTableNameConvention()
.AddAuditableEntities()
.ApplyConfigurationsFromAssembly(typeof(DialogDbContext).Assembly)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void Configure(EntityTypeBuilder<NotificationAcknowledgement> builder)
{
builder.HasKey(x => new { x.EventId, x.NotificationHandler });
builder.HasIndex(x => x.EventId);
builder.Property(x => x.NotificationHandler).HasMaxLength(Constants.DefaultMaxStringLength);
builder.Property(x => x.NotificationHandler).HasMaxLength(Domain.Common.Constants.DefaultMaxStringLength);
builder.Property(x => x.AcknowledgedAt).HasDefaultValueSql("current_timestamp at time zone 'utc'");
}
}
Loading

0 comments on commit 9708879

Please sign in to comment.