mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 19:54:55 +00:00
66819a015a
This commit introduces the MediaFile entity and updates the media attachments model, repositories, and related logic to reference MediaFile instead of storing file metadata directly in MediaAttachments. Controller, service, and SignalR request/response contracts are updated to support the new structure. Database configurations and validators are also adjusted accordingly. This refactor improves media management and normalization in the data model.
31 lines
935 B
C#
31 lines
935 B
C#
using Govor.Core.Models;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace Govor.Data.Configurations;
|
|
|
|
public class MessagesConfiguration : IEntityTypeConfiguration<Message>
|
|
{
|
|
public void Configure(EntityTypeBuilder<Message> builder)
|
|
{
|
|
builder.HasKey(m => m.Id);
|
|
|
|
builder.HasMany(m => m.Reactions)
|
|
.WithOne(r => r.Message)
|
|
.HasForeignKey(r => r.MessageId)
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
|
|
builder.HasMany(m => m.MediaAttachments)
|
|
.WithOne(ma => ma.Message)
|
|
.HasForeignKey(ma => ma.MessageId)
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
|
|
builder.HasMany(m => m.MessageViews)
|
|
.WithOne()
|
|
.HasForeignKey(mv => mv.MessageId)
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
|
|
builder.Property(m => m.EncryptedContent)
|
|
.IsRequired();
|
|
}
|
|
} |