using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace ElectronicsShopDataBaseImplement.Migrations { /// public partial class Migration02 : Migration { /// 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( name: "_productID", table: "OrderProducts", type: "int", nullable: true); migrationBuilder.CreateTable( name: "Paymeants", columns: table => new { ID = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), ProductID = table.Column(type: "int", nullable: false), OrderID = table.Column(type: "int", nullable: false), SumPayment = table.Column(type: "float", nullable: false), PayOption = table.Column(type: "int", nullable: false), PaymentID = table.Column(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); } /// 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( name: "EmployeeID", table: "Orders", type: "int", nullable: true); migrationBuilder.AddColumn( 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); } } }