Update models Messages

This commit is contained in:
Artemy
2025-06-22 11:45:25 +07:00
parent c9aad0c466
commit a6e8ba1a65
13 changed files with 794 additions and 6 deletions
@@ -0,0 +1,24 @@
using Govor.Core.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Govor.Data.Configurations;
public class MessageReactionConfiguration : IEntityTypeConfiguration<MessageReaction>
{
public void Configure(EntityTypeBuilder<MessageReaction> builder)
{
builder.HasKey(r => r.Id);
builder.HasIndex(r => new { r.MessageId, r.UserId }).IsUnique(); // Одна реакция от одного юзера
builder.Property(r => r.ReactionCode)
.IsRequired()
.HasMaxLength(64); // можно увеличить для кастомных эмодзи
builder.HasOne(r => r.User)
.WithMany()
.HasForeignKey(r => r.UserId)
.OnDelete(DeleteBehavior.Cascade);
}
}