Files
Deal/src/core/Deal.Infrastructure/Persistence/Configurations/UserConfiguration.cs
T
Rustam Khalimov 27c7831910
ci / build-test (push) Canceled after 0s
Deal — единая кодовая база
SaaS-мониторинг Telegram: ядро (модули Cards/Kanban/Pipeline/Tenants/Settings/
Discovery, Api, Infrastructure), сервисы telegram/ai/ml/storage, фронт Vue,
контракты и grpc-hosting, деплой-конфиги (dev/prod/observability/CI-раннер),
Gitea Actions CI, документация (ТЗ, техдок, api-map, код-стайл, планы, бэклог).

Текущее состояние: все этапы роадмапа 0–12 закрыты, сборка 5 sln 0/0,
тесты 1340/130/52/38/9 зелёные.
2026-09-11 23:56:47 +03:00

34 lines
1.1 KiB
C#

using Deal.Infrastructure.Persistence.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Deal.Infrastructure.Persistence.Configurations;
/// <summary>
/// EF-конфигурация пользователя
/// </summary>
public sealed class UserConfiguration : IEntityTypeConfiguration<UserEntity>
{
private const int LoginMaxLength = 200;
public void Configure(EntityTypeBuilder<UserEntity> builder)
{
builder.ToTable("users", "public");
builder.HasKey(x => x.Id);
builder.Property(x => x.Login).HasMaxLength(LoginMaxLength).IsRequired();
builder.Property(x => x.PasswordHash).IsRequired();
builder.Property(x => x.Status).IsRequired().HasDefaultValue("active");
builder.Property(x => x.CreatedAt).IsRequired().HasDefaultValueSql("now()");
builder.HasIndex(x => x.Login).IsUnique();
builder.HasIndex(x => x.TenantId);
builder.HasOne<TenantEntity>()
.WithMany()
.HasForeignKey(x => x.TenantId)
.OnDelete(DeleteBehavior.Restrict);
}
}