32 lines
1.3 KiB
C#
32 lines
1.3 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Socialize.Api.Modules.Comments.Data;
|
|
|
|
internal static class CommentModelConfiguration
|
|
{
|
|
public static ModelBuilder ConfigureCommentsModule(this ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.Entity<Comment>(comment =>
|
|
{
|
|
comment.ToTable("Comments");
|
|
comment.HasKey(x => x.Id);
|
|
comment.Property(x => x.AuthorDisplayName).HasMaxLength(256).IsRequired();
|
|
comment.Property(x => x.AuthorEmail).HasMaxLength(256).IsRequired();
|
|
comment.Property(x => x.Body).HasMaxLength(4000).IsRequired();
|
|
comment.Property(x => x.AttachmentFileName).HasMaxLength(256);
|
|
comment.Property(x => x.AttachmentContentType).HasMaxLength(128);
|
|
comment.Property(x => x.AttachmentBlobContainerName).HasMaxLength(128);
|
|
comment.Property(x => x.AttachmentBlobName).HasMaxLength(512);
|
|
comment.Property(x => x.AttachmentBlobUrl).HasMaxLength(1024);
|
|
comment.Property(x => x.CreatedAt)
|
|
.ValueGeneratedOnAdd()
|
|
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
|
comment.HasIndex(x => x.WorkspaceId);
|
|
comment.HasIndex(x => x.ContentItemId);
|
|
comment.HasIndex(x => x.ParentCommentId);
|
|
});
|
|
|
|
return modelBuilder;
|
|
}
|
|
}
|