Compare commits

..

2 Commits

Author SHA1 Message Date
khwezi 92c00360a7 Merge commit '38e765203d6a6e435e4e80368ee3dbb6c4098d2a' 2026-05-29 07:03:28 +00:00
Khwezi Mngoma 38e765203d Refactored migrations
continuous-integration/drone/pr Build is passing
2026-05-29 09:02:47 +02:00
5 changed files with 9 additions and 133 deletions
@@ -162,8 +162,5 @@
<Using Include="Microsoft.Extensions.Options" />
<Using Include="Microsoft.Extensions.Logging" />
</ItemGroup>
<ItemGroup>
<Folder Include="Postgres\Migrations\" />
</ItemGroup>
</Project>
@@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace LiteCharms.Features.MidrandBooks.Postgres.Migrations
{
[DbContext(typeof(MidrandBooksDbContext))]
[Migration("20260528052014_Init")]
[Migration("20260529070104_Init")]
partial class Init
{
/// <inheritdoc />
@@ -649,40 +649,6 @@ namespace LiteCharms.Features.MidrandBooks.Postgres.Migrations
b.ToTable("Prices", (string)null);
});
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Products.Models.ProductPrice", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<decimal>("Amount")
.HasColumnType("numeric");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<decimal>("Discount")
.HasColumnType("numeric");
b.Property<bool>("Enabled")
.HasColumnType("boolean");
b.Property<long>("ProductId")
.HasColumnType("bigint");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("ProductId")
.IsUnique();
b.ToTable("ProductPrice");
});
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.AuthorBooks.Entities.AuthorBook", b =>
{
b.HasOne("LiteCharms.Features.MidrandBooks.Authors.Entities.Author", "Author")
@@ -931,15 +897,6 @@ namespace LiteCharms.Features.MidrandBooks.Postgres.Migrations
b.Navigation("Product");
});
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Products.Models.ProductPrice", b =>
{
b.HasOne("LiteCharms.Features.MidrandBooks.Products.Entities.Product", null)
.WithOne("Price")
.HasForeignKey("LiteCharms.Features.MidrandBooks.Products.Models.ProductPrice", "ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.AuthorBooks.Entities.AuthorBook", b =>
{
b.Navigation("Pages");
@@ -973,8 +930,6 @@ namespace LiteCharms.Features.MidrandBooks.Postgres.Migrations
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Products.Entities.Product", b =>
{
b.Navigation("Price");
b.Navigation("Prices");
});
#pragma warning restore 612, 618
@@ -259,30 +259,6 @@ namespace LiteCharms.Features.MidrandBooks.Postgres.Migrations
onDelete: ReferentialAction.Restrict);
});
//migrationBuilder.CreateTable(
// name: "ProductPrice",
// columns: table => new
// {
// Id = table.Column<long>(type: "bigint", nullable: false)
// .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
// CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
// UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
// ProductId = table.Column<long>(type: "bigint", nullable: false),
// Amount = table.Column<decimal>(type: "numeric", nullable: false),
// Discount = table.Column<decimal>(type: "numeric", nullable: false),
// Enabled = table.Column<bool>(type: "boolean", nullable: false)
// },
// constraints: table =>
// {
// table.PrimaryKey("PK_ProductPrice", x => x.Id);
// table.ForeignKey(
// name: "FK_ProductPrice_Products_ProductId",
// column: x => x.ProductId,
// principalTable: "Products",
// principalColumn: "Id",
// onDelete: ReferentialAction.Cascade);
// });
migrationBuilder.CreateTable(
name: "Shippings",
columns: table => new
@@ -427,12 +403,6 @@ namespace LiteCharms.Features.MidrandBooks.Postgres.Migrations
table: "Prices",
column: "ProductId");
migrationBuilder.CreateIndex(
name: "IX_ProductPrice_ProductId",
table: "ProductPrice",
column: "ProductId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Refunds_OrderId",
table: "Refunds",
@@ -467,9 +437,6 @@ namespace LiteCharms.Features.MidrandBooks.Postgres.Migrations
migrationBuilder.DropTable(
name: "OrderItems");
migrationBuilder.DropTable(
name: "ProductPrice");
migrationBuilder.DropTable(
name: "Refunds");
@@ -57,7 +57,7 @@ namespace LiteCharms.Features.MidrandBooks.Postgres.Migrations
b.HasIndex("ProductId");
b.ToTable("Books", (string)null);
b.ToTable("Books");
});
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Authors.Entities.Author", b =>
@@ -454,7 +454,7 @@ namespace LiteCharms.Features.MidrandBooks.Postgres.Migrations
b.HasKey("Id");
b.ToTable("ShippingProviders", (string)null);
b.ToTable("ShippingProviders");
});
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Pages.Entities.BookPage", b =>
@@ -646,40 +646,6 @@ namespace LiteCharms.Features.MidrandBooks.Postgres.Migrations
b.ToTable("Prices", (string)null);
});
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Products.Models.ProductPrice", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<decimal>("Amount")
.HasColumnType("numeric");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<decimal>("Discount")
.HasColumnType("numeric");
b.Property<bool>("Enabled")
.HasColumnType("boolean");
b.Property<long>("ProductId")
.HasColumnType("bigint");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("ProductId")
.IsUnique();
b.ToTable("ProductPrice", (string)null);
});
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.AuthorBooks.Entities.AuthorBook", b =>
{
b.HasOne("LiteCharms.Features.MidrandBooks.Authors.Entities.Author", "Author")
@@ -718,7 +684,7 @@ namespace LiteCharms.Features.MidrandBooks.Postgres.Migrations
b1.HasKey("AuthorId", "__synthesizedOrdinal");
b1.ToTable("Authors", (string)null);
b1.ToTable("Authors");
b1
.ToJson("SocialMedia")
@@ -772,7 +738,7 @@ namespace LiteCharms.Features.MidrandBooks.Postgres.Migrations
b1.HasKey("CustomerId", "__synthesizedOrdinal");
b1.ToTable("Customers", (string)null);
b1.ToTable("Customers");
b1
.ToJson("SocialMedia")
@@ -862,7 +828,7 @@ namespace LiteCharms.Features.MidrandBooks.Postgres.Migrations
b1.HasKey("BookPageId", "__synthesizedOrdinal");
b1.ToTable("BookPages", (string)null);
b1.ToTable("BookPages");
b1
.ToJson("References")
@@ -904,7 +870,7 @@ namespace LiteCharms.Features.MidrandBooks.Postgres.Migrations
b1.HasKey("ProductId");
b1.ToTable("Products", (string)null);
b1.ToTable("Products");
b1
.ToJson("Metadata")
@@ -928,15 +894,6 @@ namespace LiteCharms.Features.MidrandBooks.Postgres.Migrations
b.Navigation("Product");
});
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Products.Models.ProductPrice", b =>
{
b.HasOne("LiteCharms.Features.MidrandBooks.Products.Entities.Product", null)
.WithOne("Price")
.HasForeignKey("LiteCharms.Features.MidrandBooks.Products.Models.ProductPrice", "ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.AuthorBooks.Entities.AuthorBook", b =>
{
b.Navigation("Pages");
@@ -970,8 +927,6 @@ namespace LiteCharms.Features.MidrandBooks.Postgres.Migrations
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Products.Entities.Product", b =>
{
b.Navigation("Price");
b.Navigation("Prices");
});
#pragma warning restore 612, 618
@@ -4,6 +4,8 @@ public sealed class ProductConfiguration : IEntityTypeConfiguration<Product>
{
public void Configure(EntityTypeBuilder<Product> builder)
{
builder.Ignore(p => p.Price);
builder.ToTable("Products");
builder.HasKey(f => f.Id);