CourseWorkElectronicsShop/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240526155227_Migration02.cs

176 lines
6.0 KiB
C#
Raw Normal View History

2024-05-27 14:57:41 +04:00
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ElectronicsShopDataBaseImplement.Migrations
{
/// <inheritdoc />
public partial class Migration02 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_OrderProducts_Orders__orderID",
table: "OrderProducts");
migrationBuilder.DropForeignKey(
name: "FK_OrderProducts_Products_ProductID",
table: "OrderProducts");
migrationBuilder.DropIndex(
name: "IX_OrderProducts__orderID",
table: "OrderProducts");
migrationBuilder.DropColumn(
name: "EmployeeID",
table: "Orders");
migrationBuilder.DropColumn(
name: "OrdersID",
table: "OrderProducts");
migrationBuilder.RenameColumn(
name: "_orderID",
table: "OrderProducts",
newName: "OrderID");
migrationBuilder.AddColumn<int>(
name: "_productID",
table: "OrderProducts",
type: "int",
nullable: true);
migrationBuilder.CreateTable(
name: "Paymeants",
columns: table => new
{
ID = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ProductID = table.Column<int>(type: "int", nullable: false),
OrderID = table.Column<int>(type: "int", nullable: false),
SumPayment = table.Column<double>(type: "float", nullable: false),
PayOption = table.Column<int>(type: "int", nullable: false),
PaymentID = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Paymeants", x => x.ID);
table.ForeignKey(
name: "FK_Paymeants_Orders_PaymentID",
column: x => x.PaymentID,
principalTable: "Orders",
principalColumn: "ID");
});
migrationBuilder.CreateIndex(
name: "IX_Orders_ClientID",
table: "Orders",
column: "ClientID");
migrationBuilder.CreateIndex(
name: "IX_OrderProducts__productID",
table: "OrderProducts",
column: "_productID");
migrationBuilder.CreateIndex(
name: "IX_Paymeants_PaymentID",
table: "Paymeants",
column: "PaymentID");
migrationBuilder.AddForeignKey(
name: "FK_OrderProducts_Orders_ProductID",
table: "OrderProducts",
column: "ProductID",
principalTable: "Orders",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_OrderProducts_Products__productID",
table: "OrderProducts",
column: "_productID",
principalTable: "Products",
principalColumn: "ID");
migrationBuilder.AddForeignKey(
name: "FK_Orders_Clients_ClientID",
table: "Orders",
column: "ClientID",
principalTable: "Clients",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_OrderProducts_Orders_ProductID",
table: "OrderProducts");
migrationBuilder.DropForeignKey(
name: "FK_OrderProducts_Products__productID",
table: "OrderProducts");
migrationBuilder.DropForeignKey(
name: "FK_Orders_Clients_ClientID",
table: "Orders");
migrationBuilder.DropTable(
name: "Paymeants");
migrationBuilder.DropIndex(
name: "IX_Orders_ClientID",
table: "Orders");
migrationBuilder.DropIndex(
name: "IX_OrderProducts__productID",
table: "OrderProducts");
migrationBuilder.DropColumn(
name: "_productID",
table: "OrderProducts");
migrationBuilder.RenameColumn(
name: "OrderID",
table: "OrderProducts",
newName: "_orderID");
migrationBuilder.AddColumn<int>(
name: "EmployeeID",
table: "Orders",
type: "int",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "OrdersID",
table: "OrderProducts",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateIndex(
name: "IX_OrderProducts__orderID",
table: "OrderProducts",
column: "_orderID");
migrationBuilder.AddForeignKey(
name: "FK_OrderProducts_Orders__orderID",
table: "OrderProducts",
column: "_orderID",
principalTable: "Orders",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_OrderProducts_Products_ProductID",
table: "OrderProducts",
column: "ProductID",
principalTable: "Products",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
}
}
}