Browse Source

updated order and buyer migration

pull/53/head
Galip Tolga Erdem 5 years ago
parent
commit
570e945008
  1. 27
      services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceDbContext.cs
  2. 240
      services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/20211231094501_Updated-Order-and-Buyer.Designer.cs
  3. 94
      services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/20211231094501_Updated-Order-and-Buyer.cs
  4. 45
      services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/OrderingServiceDbContextModelSnapshot.cs
  5. 13
      services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Orders/EfCoreOrderRepository.cs

27
services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceDbContext.cs

@ -33,9 +33,29 @@ namespace EShopOnAbp.OrderingService.EntityFrameworkCore
b.ToTable(OrderingServiceDbProperties.DbTablePrefix + "Buyers", OrderingServiceDbProperties.DbSchema);
b.ConfigureByConvention(); //auto configure for the base class props
b.Property(q => q.UserName).IsRequired();
b.Property(q => q.Email).IsRequired();
b.Property(q => q.Name).IsRequired();
b.Property(q => q.PaymentId).IsRequired();
b.Property<int>("_paymentTypeId").UsePropertyAccessMode(PropertyAccessMode.Field)
.HasColumnName("PaymentTypeId")
.IsRequired();
b.HasOne(q => q.PaymentType).WithMany().HasForeignKey("_paymentTypeId");
});
builder.Entity<PaymentType>(b =>
{
b.ToTable(OrderingServiceDbProperties.DbTablePrefix + "PaymentTypes",
OrderingServiceDbProperties.DbSchema);
b.ConfigureByConvention(); //auto configure for the base class props
b.HasKey(q => q.Id);
b.Property(q => q.Id)
.HasDefaultValue(1)
.ValueGeneratedNever()
.IsRequired();
b.Property(o => o.Name)
.HasMaxLength(OrderConstants.OrderPaymentTypeNameMaxLength)
.IsRequired();
});
builder.Entity<Order>(b =>
@ -46,7 +66,6 @@ namespace EShopOnAbp.OrderingService.EntityFrameworkCore
b.Property<int>("_orderStatusId").UsePropertyAccessMode(PropertyAccessMode.Field)
.HasColumnName("OrderStatusId")
.IsRequired();
b.Property(q => q.Description).HasMaxLength(OrderConstants.OrderDescriptionMaxLength).IsRequired(false);
b.HasOne<Buyer>().WithMany().HasForeignKey(q => q.BuyerId).IsRequired(false);
b.HasOne(q => q.OrderStatus).WithMany().HasForeignKey("_orderStatusId");
@ -56,7 +75,7 @@ namespace EShopOnAbp.OrderingService.EntityFrameworkCore
b.HasIndex(q => q.Id);
b.HasIndex(q => q.BuyerId);
});
// Consider removing persistancy to db or seeding
builder.Entity<OrderStatus>(b =>
{
b.ToTable(OrderingServiceDbProperties.DbTablePrefix + "OrderStatus",

240
services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/20211231094501_Updated-Order-and-Buyer.Designer.cs

@ -0,0 +1,240 @@
// <auto-generated />
using System;
using EShopOnAbp.OrderingService.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using Volo.Abp.EntityFrameworkCore;
#nullable disable
namespace EShopOnAbp.OrderingService.Migrations
{
[DbContext(typeof(OrderingServiceDbContext))]
[Migration("20211231094501_Updated-Order-and-Buyer")]
partial class UpdatedOrderandBuyer
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.PostgreSql)
.HasAnnotation("ProductVersion", "6.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("EShopOnAbp.OrderingService.Buyers.Buyer", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("character varying(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ExtraProperties")
.HasColumnType("text")
.HasColumnName("ExtraProperties");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("_paymentTypeId")
.HasColumnType("integer")
.HasColumnName("PaymentTypeId");
b.HasKey("Id");
b.HasIndex("_paymentTypeId");
b.ToTable("Buyers", (string)null);
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Buyers.PaymentType", b =>
{
b.Property<int>("Id")
.HasColumnType("integer")
.HasDefaultValue(1);
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("character varying(128)");
b.HasKey("Id");
b.ToTable("PaymentTypes", (string)null);
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.Order", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
b.Property<Guid?>("BuyerId")
.HasColumnType("uuid");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("character varying(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<string>("ExtraProperties")
.HasColumnType("text")
.HasColumnName("ExtraProperties");
b.Property<DateTime>("OrderDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("PaymentMethodToken")
.HasColumnType("text");
b.Property<int>("_orderStatusId")
.HasColumnType("integer")
.HasColumnName("OrderStatusId");
b.HasKey("Id");
b.HasIndex("BuyerId");
b.HasIndex("Id");
b.HasIndex("_orderStatusId");
b.ToTable("Orders", (string)null);
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.OrderItem", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
b.Property<decimal>("Discount")
.HasColumnType("numeric");
b.Property<Guid>("OrderId")
.HasColumnType("uuid");
b.Property<string>("PictureUrl")
.HasColumnType("text");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<string>("ProductName")
.IsRequired()
.HasColumnType("text");
b.Property<decimal>("UnitPrice")
.HasColumnType("numeric");
b.Property<int>("Units")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("OrderId");
b.ToTable("OrderItems", (string)null);
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.OrderStatus", b =>
{
b.Property<int>("Id")
.HasColumnType("integer")
.HasDefaultValue(1);
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.ToTable("OrderStatus", (string)null);
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Buyers.Buyer", b =>
{
b.HasOne("EShopOnAbp.OrderingService.Buyers.PaymentType", "PaymentType")
.WithMany()
.HasForeignKey("_paymentTypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("PaymentType");
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.Order", b =>
{
b.HasOne("EShopOnAbp.OrderingService.Buyers.Buyer", null)
.WithMany()
.HasForeignKey("BuyerId");
b.HasOne("EShopOnAbp.OrderingService.Orders.OrderStatus", "OrderStatus")
.WithMany()
.HasForeignKey("_orderStatusId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.OwnsOne("EShopOnAbp.OrderingService.Orders.Address", "Address", b1 =>
{
b1.Property<Guid>("OrderId")
.HasColumnType("uuid");
b1.Property<string>("City")
.HasColumnType("text");
b1.Property<string>("Country")
.HasColumnType("text");
b1.Property<string>("Description")
.HasColumnType("text");
b1.Property<string>("Street")
.HasColumnType("text");
b1.Property<string>("ZipCode")
.HasColumnType("text");
b1.HasKey("OrderId");
b1.ToTable("Orders");
b1.WithOwner()
.HasForeignKey("OrderId");
});
b.Navigation("Address");
b.Navigation("OrderStatus");
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.OrderItem", b =>
{
b.HasOne("EShopOnAbp.OrderingService.Orders.Order", null)
.WithMany("OrderItems")
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.Order", b =>
{
b.Navigation("OrderItems");
});
#pragma warning restore 612, 618
}
}
}

94
services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/20211231094501_Updated-Order-and-Buyer.cs

@ -0,0 +1,94 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EShopOnAbp.OrderingService.Migrations
{
public partial class UpdatedOrderandBuyer : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Description",
table: "Orders");
migrationBuilder.DropColumn(
name: "PaymentId",
table: "Buyers");
migrationBuilder.RenameColumn(
name: "UserName",
table: "Buyers",
newName: "Email");
migrationBuilder.AddColumn<int>(
name: "PaymentTypeId",
table: "Buyers",
type: "integer",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateTable(
name: "PaymentTypes",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false, defaultValue: 1),
Name = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PaymentTypes", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_Buyers_PaymentTypeId",
table: "Buyers",
column: "PaymentTypeId");
migrationBuilder.AddForeignKey(
name: "FK_Buyers_PaymentTypes_PaymentTypeId",
table: "Buyers",
column: "PaymentTypeId",
principalTable: "PaymentTypes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Buyers_PaymentTypes_PaymentTypeId",
table: "Buyers");
migrationBuilder.DropTable(
name: "PaymentTypes");
migrationBuilder.DropIndex(
name: "IX_Buyers_PaymentTypeId",
table: "Buyers");
migrationBuilder.DropColumn(
name: "PaymentTypeId",
table: "Buyers");
migrationBuilder.RenameColumn(
name: "Email",
table: "Buyers",
newName: "UserName");
migrationBuilder.AddColumn<string>(
name: "Description",
table: "Orders",
type: "character varying(1024)",
maxLength: 1024,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "PaymentId",
table: "Buyers",
type: "text",
nullable: false,
defaultValue: "");
}
}
}

45
services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/OrderingServiceDbContextModelSnapshot.cs

@ -35,6 +35,10 @@ namespace EShopOnAbp.OrderingService.Migrations
.HasColumnType("character varying(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ExtraProperties")
.HasColumnType("text")
.HasColumnName("ExtraProperties");
@ -43,17 +47,31 @@ namespace EShopOnAbp.OrderingService.Migrations
.IsRequired()
.HasColumnType("text");
b.Property<string>("PaymentId")
.IsRequired()
.HasColumnType("text");
b.Property<int>("_paymentTypeId")
.HasColumnType("integer")
.HasColumnName("PaymentTypeId");
b.HasKey("Id");
b.Property<string>("UserName")
b.HasIndex("_paymentTypeId");
b.ToTable("Buyers", (string)null);
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Buyers.PaymentType", b =>
{
b.Property<int>("Id")
.HasColumnType("integer")
.HasDefaultValue(1);
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
.HasMaxLength(128)
.HasColumnType("character varying(128)");
b.HasKey("Id");
b.ToTable("Buyers", (string)null);
b.ToTable("PaymentTypes", (string)null);
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.Order", b =>
@ -70,10 +88,6 @@ namespace EShopOnAbp.OrderingService.Migrations
.HasColumnType("character varying(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<string>("Description")
.HasMaxLength(1024)
.HasColumnType("character varying(1024)");
b.Property<string>("ExtraProperties")
.HasColumnType("text")
.HasColumnName("ExtraProperties");
@ -149,6 +163,17 @@ namespace EShopOnAbp.OrderingService.Migrations
b.ToTable("OrderStatus", (string)null);
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Buyers.Buyer", b =>
{
b.HasOne("EShopOnAbp.OrderingService.Buyers.PaymentType", "PaymentType")
.WithMany()
.HasForeignKey("_paymentTypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("PaymentType");
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.Order", b =>
{
b.HasOne("EShopOnAbp.OrderingService.Buyers.Buyer", null)

13
services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Orders/EfCoreOrderRepository.cs

@ -0,0 +1,13 @@
using System;
using EShopOnAbp.OrderingService.EntityFrameworkCore;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
namespace EShopOnAbp.OrderingService.Orders;
public class EfCoreOrderRepository : EfCoreRepository<OrderingServiceDbContext, Order, Guid>, IOrderRepository
{
public EfCoreOrderRepository(IDbContextProvider<OrderingServiceDbContext> dbContextProvider) : base(dbContextProvider)
{
}
}
Loading…
Cancel
Save