using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace DatabaseImplement.Migrations { /// public partial class purchaseitems : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "PurchaseProducts"); migrationBuilder.AddColumn( name: "PurchaseId", table: "CartItems", type: "uuid", nullable: true); migrationBuilder.CreateIndex( name: "IX_CartItems_PurchaseId", table: "CartItems", column: "PurchaseId"); migrationBuilder.AddForeignKey( name: "FK_CartItems_Purchases_PurchaseId", table: "CartItems", column: "PurchaseId", principalTable: "Purchases", principalColumn: "Id"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_CartItems_Purchases_PurchaseId", table: "CartItems"); migrationBuilder.DropIndex( name: "IX_CartItems_PurchaseId", table: "CartItems"); migrationBuilder.DropColumn( name: "PurchaseId", table: "CartItems"); migrationBuilder.CreateTable( name: "PurchaseProducts", columns: table => new { Id = table.Column(type: "uuid", nullable: false), ProductId = table.Column(type: "uuid", nullable: false), PurchaseId = table.Column(type: "uuid", nullable: false), Count = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_PurchaseProducts", x => x.Id); table.ForeignKey( name: "FK_PurchaseProducts_Products_ProductId", column: x => x.ProductId, principalTable: "Products", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_PurchaseProducts_Purchases_PurchaseId", column: x => x.PurchaseId, principalTable: "Purchases", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_PurchaseProducts_ProductId", table: "PurchaseProducts", column: "ProductId"); migrationBuilder.CreateIndex( name: "IX_PurchaseProducts_PurchaseId", table: "PurchaseProducts", column: "PurchaseId"); } } }