Added IsUnicode(false) to hostname, version, status, IP, hash, prefix, key, URL, timezone, theme, language, YOLO model name, and enum-based string columns. These columns only contain ASCII data — disabling Unicode improves PostgreSQL index efficiency and reduces storage. Excluded natural text columns (Address, DisplayName, Site.Name) that may contain Unicode characters like accented letters.
40 lines
1.0 KiB
C#
40 lines
1.0 KiB
C#
using Heimdall.Domain.Entities;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace Heimdall.Infrastructure.Data.Configurations;
|
|
|
|
public class ApiKeyConfiguration : IEntityTypeConfiguration<ApiKey>
|
|
{
|
|
public void Configure(EntityTypeBuilder<ApiKey> builder)
|
|
{
|
|
builder.ToTable("api_keys");
|
|
|
|
builder.HasKey(k => k.Id);
|
|
|
|
builder.Property(k => k.KeyHash)
|
|
.HasMaxLength(128)
|
|
.IsRequired()
|
|
.IsUnicode(false);
|
|
|
|
builder.Property(k => k.KeyPrefix)
|
|
.HasMaxLength(8)
|
|
.IsRequired()
|
|
.IsUnicode(false);
|
|
|
|
builder.Property(k => k.CreatedAt)
|
|
.HasDefaultValueSql("NOW()");
|
|
|
|
// Indexes
|
|
builder.HasIndex(k => k.KeyHash);
|
|
builder.HasIndex(k => k.KeyPrefix);
|
|
builder.HasIndex(k => k.SiteId);
|
|
|
|
// Relationships
|
|
builder.HasOne(k => k.Site)
|
|
.WithMany()
|
|
.HasForeignKey(k => k.SiteId)
|
|
.OnDelete(DeleteBehavior.Restrict);
|
|
}
|
|
}
|