Files
Khwezi Mngoma 902942eee6
continuous-integration/drone/pr Build is passing
Completed initial database design
Sealed qualifying public classes
Migrated database changes
2026-05-27 09:12:04 +02:00

23 lines
928 B
C#

namespace LiteCharms.Features.MidrandBooks.Products.Entities;
public sealed class ProductPriceConfiguration : IEntityTypeConfiguration<ProductPrice>
{
public void Configure(EntityTypeBuilder<ProductPrice> builder)
{
builder.ToTable("Prices");
builder.HasKey(f => f.Id);
builder.Property(f => f.CreatedAt).IsRequired().ValueGeneratedOnAdd().HasDefaultValueSql("now()");
builder.Property(f => f.UpdatedAt).HasDefaultValueSql("now()");
builder.Property(f => f.ProductId).IsRequired();
builder.Property(f => f.Amount).IsRequired().HasPrecision(18, 2);
builder.Property(f => f.Discount).IsRequired().HasPrecision(18, 2);
builder.Property(f => f.Enabled).HasDefaultValue(false);
builder.HasOne(f => f.Product)
.WithMany(p => p.Prices)
.HasForeignKey(f => f.ProductId)
.OnDelete(DeleteBehavior.Restrict);
}
}