Add migration for DiscountProductImages table
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 1m53s

- Created a new table `DiscountProductImages` in the CMS schema.
- Added columns for image details including `Title`, `AltText`, `ImagePath`, `ThumbnailPath`, `SortOrder`, `IsActive`, `Created`, `CreatedBy`, `LastModified`, `LastModifiedBy`, and `IsDeleted`.
- Established a foreign key relationship with the `DiscountProducts` table.
- Created indexes on `DiscountProductId` and a composite index on `DiscountProductId` and `SortOrder`.
This commit is contained in:
masoodafar-web
2026-01-01 02:26:33 +03:30
parent 500e169141
commit f0117eb1d5
29 changed files with 5068 additions and 4 deletions
@@ -0,0 +1,67 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CMSMicroservice.Infrastructure.Persistence.Migrations
{
/// <inheritdoc />
public partial class AddDiscountProductImages : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "DiscountProductImages",
schema: "CMS",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
DiscountProductId = table.Column<long>(type: "bigint", nullable: false),
Title = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
AltText = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
ImagePath = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: false),
ThumbnailPath = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
SortOrder = table.Column<int>(type: "int", nullable: false),
IsActive = table.Column<bool>(type: "bit", nullable: false),
Created = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
LastModified = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifiedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DiscountProductImages", x => x.Id);
table.ForeignKey(
name: "FK_DiscountProductImages_DiscountProducts_DiscountProductId",
column: x => x.DiscountProductId,
principalSchema: "CMS",
principalTable: "DiscountProducts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_DiscountProductImages_DiscountProductId",
schema: "CMS",
table: "DiscountProductImages",
column: "DiscountProductId");
migrationBuilder.CreateIndex(
name: "IX_DiscountProductImages_DiscountProductId_SortOrder",
schema: "CMS",
table: "DiscountProductImages",
columns: new[] { "DiscountProductId", "SortOrder" });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "DiscountProductImages",
schema: "CMS");
}
}
}
@@ -902,6 +902,64 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
b.ToTable("DiscountProductCategories", "CMS");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProductImage", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
b.Property<string>("AltText")
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.HasColumnType("nvarchar(max)");
b.Property<long>("DiscountProductId")
.HasColumnType("bigint");
b.Property<string>("ImagePath")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.Property<bool>("IsActive")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModified")
.HasColumnType("datetime2");
b.Property<string>("LastModifiedBy")
.HasColumnType("nvarchar(max)");
b.Property<int>("SortOrder")
.HasColumnType("int");
b.Property<string>("ThumbnailPath")
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.Property<string>("Title")
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.HasKey("Id");
b.HasIndex("DiscountProductId");
b.HasIndex("DiscountProductId", "SortOrder");
b.ToTable("DiscountProductImages", "CMS");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountShoppingCart", b =>
{
b.Property<long>("Id")
@@ -3026,6 +3084,17 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
b.Navigation("Product");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProductImage", b =>
{
b.HasOne("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProduct", "DiscountProduct")
.WithMany("Images")
.HasForeignKey("DiscountProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("DiscountProduct");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountShoppingCart", b =>
{
b.HasOne("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProduct", "Product")
@@ -3439,6 +3508,8 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProduct", b =>
{
b.Navigation("Images");
b.Navigation("OrderDetails");
b.Navigation("ProductCategories");