- клонирование коллекции - добавление паблик-коллекций - регенерация паблик-ссылок
47 lines
1.5 KiB
C#
47 lines
1.5 KiB
C#
using MemeVault.Domain.Aggregates.BotUser;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace MemeVault.Infrastructure.Persistence.Configurations;
|
|
|
|
public sealed class BotUserConfiguration : IEntityTypeConfiguration<BotUser>
|
|
{
|
|
public void Configure(EntityTypeBuilder<BotUser> builder)
|
|
{
|
|
builder.ToTable("bot_users");
|
|
|
|
builder.HasKey(x => x.Id);
|
|
builder.Property(x => x.Id).HasColumnName("id");
|
|
|
|
builder.Property(x => x.TelegramId)
|
|
.HasColumnName("telegram_id")
|
|
.IsRequired();
|
|
|
|
builder.HasIndex(x => x.TelegramId)
|
|
.IsUnique()
|
|
.HasDatabaseName("ix_bot_users_telegram_id");
|
|
|
|
builder.Property(x => x.Username)
|
|
.HasColumnName("username")
|
|
.HasMaxLength(64)
|
|
.IsRequired();
|
|
|
|
builder.Property(x => x.FirstName)
|
|
.HasColumnName("first_name")
|
|
.HasMaxLength(64);
|
|
|
|
builder.Property(x => x.CreatedAt).HasColumnName("created_at");
|
|
builder.Property(x => x.LastSeenAt).HasColumnName("last_seen_at");
|
|
|
|
builder.Property(x => x.InboxCollectionId)
|
|
.HasColumnName("inbox_collection_id");
|
|
|
|
// FK → collections.id; без навигационного свойства на агрегате
|
|
builder.HasOne<Domain.Aggregates.Collection.Collection>()
|
|
.WithMany()
|
|
.HasForeignKey(u => u.InboxCollectionId)
|
|
.IsRequired(false)
|
|
.OnDelete(DeleteBehavior.SetNull);
|
|
}
|
|
}
|