|
@ -1,17 +1,20 @@ |
|
|
using System; |
|
|
using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using Microsoft.EntityFrameworkCore.Migrations; |
|
|
using Microsoft.EntityFrameworkCore.Migrations; |
|
|
using Microsoft.EntityFrameworkCore.Metadata; |
|
|
|
|
|
|
|
|
|
|
|
namespace Ordering.API.Infrastructure.Migrations |
|
|
|
|
|
|
|
|
namespace Ordering.API.Migrations |
|
|
{ |
|
|
{ |
|
|
public partial class InitialModel : Migration |
|
|
|
|
|
|
|
|
public partial class Initial : Migration |
|
|
{ |
|
|
{ |
|
|
protected override void Up(MigrationBuilder migrationBuilder) |
|
|
protected override void Up(MigrationBuilder migrationBuilder) |
|
|
{ |
|
|
{ |
|
|
migrationBuilder.EnsureSchema( |
|
|
migrationBuilder.EnsureSchema( |
|
|
name: "ordering"); |
|
|
name: "ordering"); |
|
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateSequence( |
|
|
|
|
|
name: "orderitemseq", |
|
|
|
|
|
incrementBy: 10); |
|
|
|
|
|
|
|
|
migrationBuilder.CreateSequence( |
|
|
migrationBuilder.CreateSequence( |
|
|
name: "buyerseq", |
|
|
name: "buyerseq", |
|
|
schema: "ordering", |
|
|
schema: "ordering", |
|
@ -27,24 +30,6 @@ namespace Ordering.API.Infrastructure.Migrations |
|
|
schema: "ordering", |
|
|
schema: "ordering", |
|
|
incrementBy: 10); |
|
|
incrementBy: 10); |
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable( |
|
|
|
|
|
name: "address", |
|
|
|
|
|
schema: "ordering", |
|
|
|
|
|
columns: table => new |
|
|
|
|
|
{ |
|
|
|
|
|
Id = table.Column<int>(nullable: false) |
|
|
|
|
|
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), |
|
|
|
|
|
City = table.Column<string>(nullable: true), |
|
|
|
|
|
Country = table.Column<string>(nullable: true), |
|
|
|
|
|
State = table.Column<string>(nullable: true), |
|
|
|
|
|
Street = table.Column<string>(nullable: true), |
|
|
|
|
|
ZipCode = table.Column<string>(nullable: true) |
|
|
|
|
|
}, |
|
|
|
|
|
constraints: table => |
|
|
|
|
|
{ |
|
|
|
|
|
table.PrimaryKey("PK_address", x => x.Id); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable( |
|
|
migrationBuilder.CreateTable( |
|
|
name: "buyers", |
|
|
name: "buyers", |
|
|
schema: "ordering", |
|
|
schema: "ordering", |
|
@ -90,12 +75,12 @@ namespace Ordering.API.Infrastructure.Migrations |
|
|
columns: table => new |
|
|
columns: table => new |
|
|
{ |
|
|
{ |
|
|
Id = table.Column<int>(nullable: false), |
|
|
Id = table.Column<int>(nullable: false), |
|
|
|
|
|
Alias = table.Column<string>(maxLength: 200, nullable: false), |
|
|
BuyerId = table.Column<int>(nullable: false), |
|
|
BuyerId = table.Column<int>(nullable: false), |
|
|
CardHolderName = table.Column<string>(maxLength: 200, nullable: false), |
|
|
CardHolderName = table.Column<string>(maxLength: 200, nullable: false), |
|
|
CardNumber = table.Column<string>(maxLength: 25, nullable: false), |
|
|
CardNumber = table.Column<string>(maxLength: 25, nullable: false), |
|
|
CardTypeId = table.Column<int>(nullable: false), |
|
|
CardTypeId = table.Column<int>(nullable: false), |
|
|
Expiration = table.Column<DateTime>(nullable: false), |
|
|
|
|
|
SecurityNumber = table.Column<string>(nullable: true) |
|
|
|
|
|
|
|
|
Expiration = table.Column<DateTime>(nullable: false) |
|
|
}, |
|
|
}, |
|
|
constraints: table => |
|
|
constraints: table => |
|
|
{ |
|
|
{ |
|
@ -123,10 +108,13 @@ namespace Ordering.API.Infrastructure.Migrations |
|
|
{ |
|
|
{ |
|
|
Id = table.Column<int>(nullable: false), |
|
|
Id = table.Column<int>(nullable: false), |
|
|
BuyerId = table.Column<int>(nullable: false), |
|
|
BuyerId = table.Column<int>(nullable: false), |
|
|
|
|
|
City = table.Column<string>(nullable: false), |
|
|
OrderDate = table.Column<DateTime>(nullable: false), |
|
|
OrderDate = table.Column<DateTime>(nullable: false), |
|
|
|
|
|
OrderStatusId = table.Column<int>(nullable: false), |
|
|
PaymentId = table.Column<int>(nullable: false), |
|
|
PaymentId = table.Column<int>(nullable: false), |
|
|
ShippingAddressId = table.Column<int>(nullable: true), |
|
|
|
|
|
StatusId = table.Column<int>(nullable: false) |
|
|
|
|
|
|
|
|
State = table.Column<string>(nullable: false), |
|
|
|
|
|
Street = table.Column<string>(nullable: false), |
|
|
|
|
|
ZipCode = table.Column<string>(nullable: false) |
|
|
}, |
|
|
}, |
|
|
constraints: table => |
|
|
constraints: table => |
|
|
{ |
|
|
{ |
|
@ -139,26 +127,19 @@ namespace Ordering.API.Infrastructure.Migrations |
|
|
principalColumn: "Id", |
|
|
principalColumn: "Id", |
|
|
onDelete: ReferentialAction.Cascade); |
|
|
onDelete: ReferentialAction.Cascade); |
|
|
table.ForeignKey( |
|
|
table.ForeignKey( |
|
|
name: "FK_orders_payments_PaymentId", |
|
|
|
|
|
column: x => x.PaymentId, |
|
|
|
|
|
|
|
|
name: "FK_orders_orderstatus_OrderStatusId", |
|
|
|
|
|
column: x => x.OrderStatusId, |
|
|
principalSchema: "ordering", |
|
|
principalSchema: "ordering", |
|
|
principalTable: "payments", |
|
|
|
|
|
|
|
|
principalTable: "orderstatus", |
|
|
principalColumn: "Id", |
|
|
principalColumn: "Id", |
|
|
onDelete: ReferentialAction.Restrict); |
|
|
|
|
|
|
|
|
onDelete: ReferentialAction.Cascade); |
|
|
table.ForeignKey( |
|
|
table.ForeignKey( |
|
|
name: "FK_orders_address_ShippingAddressId", |
|
|
|
|
|
column: x => x.ShippingAddressId, |
|
|
|
|
|
|
|
|
name: "FK_orders_payments_PaymentId", |
|
|
|
|
|
column: x => x.PaymentId, |
|
|
principalSchema: "ordering", |
|
|
principalSchema: "ordering", |
|
|
principalTable: "address", |
|
|
|
|
|
|
|
|
principalTable: "payments", |
|
|
principalColumn: "Id", |
|
|
principalColumn: "Id", |
|
|
onDelete: ReferentialAction.Restrict); |
|
|
onDelete: ReferentialAction.Restrict); |
|
|
table.ForeignKey( |
|
|
|
|
|
name: "FK_orders_orderstatus_StatusId", |
|
|
|
|
|
column: x => x.StatusId, |
|
|
|
|
|
principalSchema: "ordering", |
|
|
|
|
|
principalTable: "orderstatus", |
|
|
|
|
|
principalColumn: "Id", |
|
|
|
|
|
onDelete: ReferentialAction.Cascade); |
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable( |
|
|
migrationBuilder.CreateTable( |
|
@ -166,15 +147,13 @@ namespace Ordering.API.Infrastructure.Migrations |
|
|
schema: "ordering", |
|
|
schema: "ordering", |
|
|
columns: table => new |
|
|
columns: table => new |
|
|
{ |
|
|
{ |
|
|
Id = table.Column<int>(nullable: false) |
|
|
|
|
|
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), |
|
|
|
|
|
|
|
|
Id = table.Column<int>(nullable: false), |
|
|
Discount = table.Column<decimal>(nullable: false), |
|
|
Discount = table.Column<decimal>(nullable: false), |
|
|
OrderId = table.Column<int>(nullable: false), |
|
|
OrderId = table.Column<int>(nullable: false), |
|
|
ProductId = table.Column<int>(nullable: false), |
|
|
ProductId = table.Column<int>(nullable: false), |
|
|
ProductName = table.Column<string>(nullable: false), |
|
|
ProductName = table.Column<string>(nullable: false), |
|
|
PictureUrl = table.Column<string>(nullable: false), |
|
|
|
|
|
UnitPrice = table.Column<decimal>(nullable: false), |
|
|
UnitPrice = table.Column<decimal>(nullable: false), |
|
|
Units = table.Column<int>(nullable: false, defaultValue: 1) |
|
|
|
|
|
|
|
|
Units = table.Column<int>(nullable: false) |
|
|
}, |
|
|
}, |
|
|
constraints: table => |
|
|
constraints: table => |
|
|
{ |
|
|
{ |
|
@ -196,62 +175,44 @@ namespace Ordering.API.Infrastructure.Migrations |
|
|
unique: true); |
|
|
unique: true); |
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex( |
|
|
migrationBuilder.CreateIndex( |
|
|
name: "IX_orders_BuyerId", |
|
|
|
|
|
|
|
|
name: "IX_payments_BuyerId", |
|
|
schema: "ordering", |
|
|
schema: "ordering", |
|
|
table: "orders", |
|
|
|
|
|
|
|
|
table: "payments", |
|
|
column: "BuyerId"); |
|
|
column: "BuyerId"); |
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex( |
|
|
migrationBuilder.CreateIndex( |
|
|
name: "IX_orders_PaymentId", |
|
|
|
|
|
|
|
|
name: "IX_payments_CardTypeId", |
|
|
|
|
|
schema: "ordering", |
|
|
|
|
|
table: "payments", |
|
|
|
|
|
column: "CardTypeId"); |
|
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex( |
|
|
|
|
|
name: "IX_orders_BuyerId", |
|
|
schema: "ordering", |
|
|
schema: "ordering", |
|
|
table: "orders", |
|
|
table: "orders", |
|
|
column: "PaymentId"); |
|
|
|
|
|
|
|
|
column: "BuyerId"); |
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex( |
|
|
migrationBuilder.CreateIndex( |
|
|
name: "IX_orders_ShippingAddressId", |
|
|
|
|
|
|
|
|
name: "IX_orders_OrderStatusId", |
|
|
schema: "ordering", |
|
|
schema: "ordering", |
|
|
table: "orders", |
|
|
table: "orders", |
|
|
column: "ShippingAddressId"); |
|
|
|
|
|
|
|
|
column: "OrderStatusId"); |
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex( |
|
|
migrationBuilder.CreateIndex( |
|
|
name: "IX_orders_StatusId", |
|
|
|
|
|
|
|
|
name: "IX_orders_PaymentId", |
|
|
schema: "ordering", |
|
|
schema: "ordering", |
|
|
table: "orders", |
|
|
table: "orders", |
|
|
column: "StatusId"); |
|
|
|
|
|
|
|
|
column: "PaymentId"); |
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex( |
|
|
migrationBuilder.CreateIndex( |
|
|
name: "IX_orderItems_OrderId", |
|
|
name: "IX_orderItems_OrderId", |
|
|
schema: "ordering", |
|
|
schema: "ordering", |
|
|
table: "orderItems", |
|
|
table: "orderItems", |
|
|
column: "OrderId"); |
|
|
column: "OrderId"); |
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex( |
|
|
|
|
|
name: "IX_payments_BuyerId", |
|
|
|
|
|
schema: "ordering", |
|
|
|
|
|
table: "payments", |
|
|
|
|
|
column: "BuyerId"); |
|
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex( |
|
|
|
|
|
name: "IX_payments_CardTypeId", |
|
|
|
|
|
schema: "ordering", |
|
|
|
|
|
table: "payments", |
|
|
|
|
|
column: "CardTypeId"); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected override void Down(MigrationBuilder migrationBuilder) |
|
|
protected override void Down(MigrationBuilder migrationBuilder) |
|
|
{ |
|
|
{ |
|
|
migrationBuilder.DropSequence( |
|
|
|
|
|
name: "buyerseq", |
|
|
|
|
|
schema: "ordering"); |
|
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropSequence( |
|
|
|
|
|
name: "orderseq", |
|
|
|
|
|
schema: "ordering"); |
|
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropSequence( |
|
|
|
|
|
name: "paymentseq", |
|
|
|
|
|
schema: "ordering"); |
|
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable( |
|
|
migrationBuilder.DropTable( |
|
|
name: "orderItems", |
|
|
name: "orderItems", |
|
|
schema: "ordering"); |
|
|
schema: "ordering"); |
|
@ -261,15 +222,11 @@ namespace Ordering.API.Infrastructure.Migrations |
|
|
schema: "ordering"); |
|
|
schema: "ordering"); |
|
|
|
|
|
|
|
|
migrationBuilder.DropTable( |
|
|
migrationBuilder.DropTable( |
|
|
name: "payments", |
|
|
|
|
|
schema: "ordering"); |
|
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable( |
|
|
|
|
|
name: "address", |
|
|
|
|
|
|
|
|
name: "orderstatus", |
|
|
schema: "ordering"); |
|
|
schema: "ordering"); |
|
|
|
|
|
|
|
|
migrationBuilder.DropTable( |
|
|
migrationBuilder.DropTable( |
|
|
name: "orderstatus", |
|
|
|
|
|
|
|
|
name: "payments", |
|
|
schema: "ordering"); |
|
|
schema: "ordering"); |
|
|
|
|
|
|
|
|
migrationBuilder.DropTable( |
|
|
migrationBuilder.DropTable( |
|
@ -279,6 +236,21 @@ namespace Ordering.API.Infrastructure.Migrations |
|
|
migrationBuilder.DropTable( |
|
|
migrationBuilder.DropTable( |
|
|
name: "cardtypes", |
|
|
name: "cardtypes", |
|
|
schema: "ordering"); |
|
|
schema: "ordering"); |
|
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropSequence( |
|
|
|
|
|
name: "orderitemseq"); |
|
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropSequence( |
|
|
|
|
|
name: "buyerseq", |
|
|
|
|
|
schema: "ordering"); |
|
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropSequence( |
|
|
|
|
|
name: "orderseq", |
|
|
|
|
|
schema: "ordering"); |
|
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropSequence( |
|
|
|
|
|
name: "paymentseq", |
|
|
|
|
|
schema: "ordering"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |