using FluentMigrator; using FluentMigrator.Builders.Create.Table; using Nop.Data.Mapping.Builders; using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities; using Nop.Data.Extensions; using System.Data; using Nop.Core.Domain.Catalog; using Nop.Core.Domain.Common; using Nop.Data.Mapping; namespace Nop.Plugin.Misc.AuctionPlugin.Mapping.Builders; public class ProductToAuctionMappingBuilder : NopEntityBuilder { #region Methods /// /// Apply entity configuration /// /// Create table expression builder public override void MapEntity(CreateTableExpressionBuilder table) { table.WithColumn(nameof(ProductToAuctionMapping.Id)).AsInt32().PrimaryKey().Identity() .WithColumn(nameof(ProductToAuctionMapping.AuctionId)).AsInt32().ForeignKey(onDelete: Rule.Cascade) //Rule.Cascade?? .WithColumn(nameof(ProductToAuctionMapping.ProductId)).AsInt32().ForeignKey(onDelete: Rule.Cascade) //Rule.Cascade?? .WithColumn(nameof(ProductToAuctionMapping.AuctionStatus)).AsByte().NotNullable() .WithColumn(nameof(ProductToAuctionMapping.StartingPrice)).AsInt32().NotNullable() .WithColumn(nameof(ProductToAuctionMapping.CurrentPrice)).AsInt32().NotNullable() .WithColumn(nameof(ProductToAuctionMapping.ProductAmount)).AsInt32().NotNullable().WithDefaultValue(1) .WithColumn(nameof(ProductToAuctionMapping.SortIndex)).AsInt32().NotNullable().WithDefaultValue(0) .WithColumn(nameof(ProductToAuctionMapping.Created)).AsDateTime().NotNullable() .WithColumn(nameof(ProductToAuctionMapping.Modified)).AsDateTime().NotNullable().WithDefault(SystemMethods.CurrentUTCDateTime); } #endregion }