image änderungen
This commit is contained in:
@@ -29,6 +29,7 @@ namespace Webshop.Infrastructure.Data
|
||||
public DbSet<Productcategorie> Productcategories { get; set; } = default!;
|
||||
public DbSet<ProductDiscount> ProductDiscounts { get; set; } = default!;
|
||||
public DbSet<CategorieDiscount> categorieDiscounts { get; set; } = default!;
|
||||
public DbSet<ProductImage> ProductImages { get; set; } = default!;
|
||||
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
@@ -67,6 +68,16 @@ namespace Webshop.Infrastructure.Data
|
||||
e.Property(p => p.Length).HasPrecision(18, 2);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<ProductImage>(entity =>
|
||||
{
|
||||
entity.ToTable("ProductImages");
|
||||
|
||||
entity.HasOne(pi => pi.Product)
|
||||
.WithMany(p => p.Images)
|
||||
.HasForeignKey(pi => pi.ProductId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<ProductVariant>()
|
||||
.Property(pv => pv.PriceAdjustment).HasPrecision(18, 2);
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ using Webshop.Infrastructure.Data;
|
||||
namespace Webshop.Infrastructure.Migrations
|
||||
{
|
||||
[DbContext(typeof(ApplicationDbContext))]
|
||||
[Migration("20250801133504_FinalSchema")]
|
||||
partial class FinalSchema
|
||||
[Migration("20250806081749_images")]
|
||||
partial class images
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
@@ -580,10 +580,6 @@ namespace Webshop.Infrastructure.Migrations
|
||||
.HasPrecision(18, 2)
|
||||
.HasColumnType("numeric(18,2)");
|
||||
|
||||
b.Property<string>("ImageUrl")
|
||||
.HasMaxLength(2000)
|
||||
.HasColumnType("character varying(2000)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
@@ -670,6 +666,32 @@ namespace Webshop.Infrastructure.Migrations
|
||||
b.ToTable("ProductDiscounts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Webshop.Domain.Entities.ProductImage", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("DisplayOrder")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool>("IsMainImage")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Url")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.ToTable("ProductImages", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Webshop.Domain.Entities.ProductVariant", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
@@ -1136,6 +1158,17 @@ namespace Webshop.Infrastructure.Migrations
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Webshop.Domain.Entities.ProductImage", b =>
|
||||
{
|
||||
b.HasOne("Webshop.Domain.Entities.Product", "Product")
|
||||
.WithMany("Images")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Webshop.Domain.Entities.ProductVariant", b =>
|
||||
{
|
||||
b.HasOne("Webshop.Domain.Entities.Product", "Product")
|
||||
@@ -1224,6 +1257,8 @@ namespace Webshop.Infrastructure.Migrations
|
||||
|
||||
modelBuilder.Entity("Webshop.Domain.Entities.Product", b =>
|
||||
{
|
||||
b.Navigation("Images");
|
||||
|
||||
b.Navigation("ProductDiscounts");
|
||||
|
||||
b.Navigation("Productcategories");
|
||||
@@ -7,7 +7,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
namespace Webshop.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class FinalSchema : Migration
|
||||
public partial class images : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
@@ -432,7 +432,6 @@ namespace Webshop.Infrastructure.Migrations
|
||||
Width = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: true),
|
||||
Height = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: true),
|
||||
Length = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: true),
|
||||
ImageUrl = table.Column<string>(type: "character varying(2000)", maxLength: 2000, nullable: true),
|
||||
Slug = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
|
||||
CreatedDate = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||
LastModifiedDate = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||
@@ -497,6 +496,27 @@ namespace Webshop.Infrastructure.Migrations
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ProductImages",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Url = table.Column<string>(type: "text", nullable: false),
|
||||
IsMainImage = table.Column<bool>(type: "boolean", nullable: false),
|
||||
DisplayOrder = table.Column<int>(type: "integer", nullable: false),
|
||||
ProductId = table.Column<Guid>(type: "uuid", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ProductImages", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ProductImages_Products_ProductId",
|
||||
column: x => x.ProductId,
|
||||
principalTable: "Products",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ProductVariants",
|
||||
columns: table => new
|
||||
@@ -678,6 +698,11 @@ namespace Webshop.Infrastructure.Migrations
|
||||
table: "ProductDiscounts",
|
||||
column: "DiscountId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProductImages_ProductId",
|
||||
table: "ProductImages",
|
||||
column: "ProductId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Products_SKU",
|
||||
table: "Products",
|
||||
@@ -774,6 +799,9 @@ namespace Webshop.Infrastructure.Migrations
|
||||
migrationBuilder.DropTable(
|
||||
name: "ProductDiscounts");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ProductImages");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Reviews");
|
||||
|
||||
@@ -577,10 +577,6 @@ namespace Webshop.Infrastructure.Migrations
|
||||
.HasPrecision(18, 2)
|
||||
.HasColumnType("numeric(18,2)");
|
||||
|
||||
b.Property<string>("ImageUrl")
|
||||
.HasMaxLength(2000)
|
||||
.HasColumnType("character varying(2000)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
@@ -667,6 +663,32 @@ namespace Webshop.Infrastructure.Migrations
|
||||
b.ToTable("ProductDiscounts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Webshop.Domain.Entities.ProductImage", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("DisplayOrder")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool>("IsMainImage")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Url")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.ToTable("ProductImages", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Webshop.Domain.Entities.ProductVariant", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
@@ -1133,6 +1155,17 @@ namespace Webshop.Infrastructure.Migrations
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Webshop.Domain.Entities.ProductImage", b =>
|
||||
{
|
||||
b.HasOne("Webshop.Domain.Entities.Product", "Product")
|
||||
.WithMany("Images")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Webshop.Domain.Entities.ProductVariant", b =>
|
||||
{
|
||||
b.HasOne("Webshop.Domain.Entities.Product", "Product")
|
||||
@@ -1221,6 +1254,8 @@ namespace Webshop.Infrastructure.Migrations
|
||||
|
||||
modelBuilder.Entity("Webshop.Domain.Entities.Product", b =>
|
||||
{
|
||||
b.Navigation("Images");
|
||||
|
||||
b.Navigation("ProductDiscounts");
|
||||
|
||||
b.Navigation("Productcategories");
|
||||
|
||||
Reference in New Issue
Block a user