Files
Deal/src/core/Deal.Infrastructure/Persistence/Configurations/InviteConfiguration.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

37 lines
1.5 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 InviteConfiguration : IEntityTypeConfiguration<InviteEntity>
{
private const int EmailMaxLength = 200;
public void Configure(EntityTypeBuilder<InviteEntity> builder)
{
builder.ToTable("invites", "public");
builder.HasKey(x => x.Code);
builder.Property(x => x.Email).HasMaxLength(EmailMaxLength).IsRequired();
builder.Property(x => x.TenantId);
builder.Property(x => x.Status).IsRequired().HasDefaultValue("pending");
builder.Property(x => x.ExpiresAt).IsRequired();
builder.Property(x => x.ActivatedAt);
builder.Property(x => x.CreatedAt).IsRequired();
// Email уникален среди активных (pending) инвайтов: после активации/отзыва/истечения он
// освобождается — глобальную уникальность регистрации держит unique-индекс users.Login.
builder.HasIndex(x => x.Email).IsUnique().HasFilter("\"Status\" = 'pending'");
builder.HasOne<OperatorEntity>()
.WithMany()
.HasForeignKey(x => x.CreatedById)
.OnDelete(DeleteBehavior.Restrict);
}
}