using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace WebAPIWithEF.Migrations { /// public partial class ModelRevisions : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Toppings_Pizzas_PizzaId", table: "Toppings"); migrationBuilder.DropIndex( name: "IX_Toppings_PizzaId", table: "Toppings"); migrationBuilder.DropColumn( name: "PizzaId", table: "Toppings"); migrationBuilder.AlterColumn( name: "Name", table: "Toppings", type: "TEXT", maxLength: 100, nullable: false, defaultValue: "", oldClrType: typeof(string), oldType: "TEXT", oldNullable: true); migrationBuilder.AddColumn( name: "Calories", table: "Toppings", type: "TEXT", nullable: false, defaultValue: 0m); migrationBuilder.AlterColumn( name: "Name", table: "Sauces", type: "TEXT", maxLength: 100, nullable: false, defaultValue: "", oldClrType: typeof(string), oldType: "TEXT", oldNullable: true); migrationBuilder.AddColumn( name: "IsVegan", table: "Sauces", type: "INTEGER", nullable: false, defaultValue: false); migrationBuilder.AlterColumn( name: "Name", table: "Pizzas", type: "TEXT", maxLength: 100, nullable: false, defaultValue: "", oldClrType: typeof(string), oldType: "TEXT", oldNullable: true); migrationBuilder.CreateTable( name: "PizzaTopping", columns: table => new { PizzasId = table.Column(type: "INTEGER", nullable: false), ToppingsId = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_PizzaTopping", x => new { x.PizzasId, x.ToppingsId }); table.ForeignKey( name: "FK_PizzaTopping_Pizzas_PizzasId", column: x => x.PizzasId, principalTable: "Pizzas", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_PizzaTopping_Toppings_ToppingsId", column: x => x.ToppingsId, principalTable: "Toppings", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_PizzaTopping_ToppingsId", table: "PizzaTopping", column: "ToppingsId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "PizzaTopping"); migrationBuilder.DropColumn( name: "Calories", table: "Toppings"); migrationBuilder.DropColumn( name: "IsVegan", table: "Sauces"); migrationBuilder.AlterColumn( name: "Name", table: "Toppings", type: "TEXT", nullable: true, oldClrType: typeof(string), oldType: "TEXT", oldMaxLength: 100); migrationBuilder.AddColumn( name: "PizzaId", table: "Toppings", type: "INTEGER", nullable: true); migrationBuilder.AlterColumn( name: "Name", table: "Sauces", type: "TEXT", nullable: true, oldClrType: typeof(string), oldType: "TEXT", oldMaxLength: 100); migrationBuilder.AlterColumn( name: "Name", table: "Pizzas", type: "TEXT", nullable: true, oldClrType: typeof(string), oldType: "TEXT", oldMaxLength: 100); migrationBuilder.CreateIndex( name: "IX_Toppings_PizzaId", table: "Toppings", column: "PizzaId"); migrationBuilder.AddForeignKey( name: "FK_Toppings_Pizzas_PizzaId", table: "Toppings", column: "PizzaId", principalTable: "Pizzas", principalColumn: "Id"); } } }