using FileService.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace FileService.Infrastructure.Configs { public class UploadTaskConfig : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable("upload_tasks"); builder.Property(x => x.FileName) .HasMaxLength(255) .HasConversion( a => a.Value, b => new Domain.ValueObjects.FileName(b) ); builder.Property(x => x.ContentType) .HasMaxLength(255) .HasConversion( a => a.Value, b => new Domain.ValueObjects.ContentType(b) ); builder.ComplexProperty(x => x.CheckSum, c => { c.Property(p => p.Value) .HasMaxLength(128) .HasColumnName("checksum_value"); c.Property(p => p.Algorithm) .HasMaxLength(16) .HasColumnName("checksum_algorithm"); }); builder.Property(x => x.FailureReason).HasMaxLength(500); builder.Property(x => x.ChatType).HasMaxLength(16); builder.ComplexProperty(x => x.StorageLocation, c => { c.Property(p => p.StorageProvider) .HasMaxLength(64) .HasColumnName("storage_provider"); c.Property(p => p.ObjectKey) .HasMaxLength(1024) .HasColumnName("storage_key"); c.Property(p => p.Region) .HasMaxLength(128) .HasColumnName("storage_region"); c.Property(p => p.Bucket) .HasMaxLength(255) .HasColumnName("storage_bucket"); }); } } }