|
|
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
|
|
|
|
|
|
#nullable disable
|
|
|
|
|
|
|
|
|
|
namespace WebAPIWithEF.Migrations
|
|
|
|
|
{
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
public partial class ModelRevisions : Migration
|
|
|
|
|
{
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
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<string>(
|
|
|
|
|
name: "Name",
|
|
|
|
|
table: "Toppings",
|
|
|
|
|
type: "TEXT",
|
|
|
|
|
maxLength: 100,
|
|
|
|
|
nullable: false,
|
|
|
|
|
defaultValue: "",
|
|
|
|
|
oldClrType: typeof(string),
|
|
|
|
|
oldType: "TEXT",
|
|
|
|
|
oldNullable: true);
|
|
|
|
|
|
|
|
|
|
migrationBuilder.AddColumn<decimal>(
|
|
|
|
|
name: "Calories",
|
|
|
|
|
table: "Toppings",
|
|
|
|
|
type: "TEXT",
|
|
|
|
|
nullable: false,
|
|
|
|
|
defaultValue: 0m);
|
|
|
|
|
|
|
|
|
|
migrationBuilder.AlterColumn<string>(
|
|
|
|
|
name: "Name",
|
|
|
|
|
table: "Sauces",
|
|
|
|
|
type: "TEXT",
|
|
|
|
|
maxLength: 100,
|
|
|
|
|
nullable: false,
|
|
|
|
|
defaultValue: "",
|
|
|
|
|
oldClrType: typeof(string),
|
|
|
|
|
oldType: "TEXT",
|
|
|
|
|
oldNullable: true);
|
|
|
|
|
|
|
|
|
|
migrationBuilder.AddColumn<bool>(
|
|
|
|
|
name: "IsVegan",
|
|
|
|
|
table: "Sauces",
|
|
|
|
|
type: "INTEGER",
|
|
|
|
|
nullable: false,
|
|
|
|
|
defaultValue: false);
|
|
|
|
|
|
|
|
|
|
migrationBuilder.AlterColumn<string>(
|
|
|
|
|
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<int>(type: "INTEGER", nullable: false),
|
|
|
|
|
ToppingsId = table.Column<int>(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");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
|
|
|
{
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "PizzaTopping");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropColumn(
|
|
|
|
|
name: "Calories",
|
|
|
|
|
table: "Toppings");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropColumn(
|
|
|
|
|
name: "IsVegan",
|
|
|
|
|
table: "Sauces");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.AlterColumn<string>(
|
|
|
|
|
name: "Name",
|
|
|
|
|
table: "Toppings",
|
|
|
|
|
type: "TEXT",
|
|
|
|
|
nullable: true,
|
|
|
|
|
oldClrType: typeof(string),
|
|
|
|
|
oldType: "TEXT",
|
|
|
|
|
oldMaxLength: 100);
|
|
|
|
|
|
|
|
|
|
migrationBuilder.AddColumn<int>(
|
|
|
|
|
name: "PizzaId",
|
|
|
|
|
table: "Toppings",
|
|
|
|
|
type: "INTEGER",
|
|
|
|
|
nullable: true);
|
|
|
|
|
|
|
|
|
|
migrationBuilder.AlterColumn<string>(
|
|
|
|
|
name: "Name",
|
|
|
|
|
table: "Sauces",
|
|
|
|
|
type: "TEXT",
|
|
|
|
|
nullable: true,
|
|
|
|
|
oldClrType: typeof(string),
|
|
|
|
|
oldType: "TEXT",
|
|
|
|
|
oldMaxLength: 100);
|
|
|
|
|
|
|
|
|
|
migrationBuilder.AlterColumn<string>(
|
|
|
|
|
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");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|