using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Francesco.Recipes.World.Migrations { /// public partial class RemoveUnnecessaryStuff : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { if (migrationBuilder == null) { throw new ArgumentNullException(nameof(migrationBuilder)); } migrationBuilder.DropColumn( name: "StepDescription", table: "Instructions"); migrationBuilder.DropColumn( name: "StepNumber", table: "Instructions"); migrationBuilder.DropColumn( name: "Unit", table: "Ingredients"); migrationBuilder.AlterColumn( name: "Name", table: "Recipes", type: "nvarchar(max)", nullable: false, defaultValue: "", oldClrType: typeof(string), oldType: "nvarchar(max)", oldNullable: true); migrationBuilder.AlterColumn( name: "Difficulty", table: "Recipes", type: "nvarchar(max)", nullable: false, defaultValue: "", oldClrType: typeof(string), oldType: "nvarchar(max)", oldNullable: true); migrationBuilder.AlterColumn( name: "Description", table: "Recipes", type: "nvarchar(max)", nullable: false, defaultValue: "", oldClrType: typeof(string), oldType: "nvarchar(max)", oldNullable: true); migrationBuilder.AddColumn( name: "Description", table: "Instructions", type: "nvarchar(max)", nullable: false, defaultValue: ""); migrationBuilder.AddColumn( name: "Number", table: "Instructions", type: "nvarchar(max)", nullable: false, defaultValue: ""); migrationBuilder.AlterColumn( name: "Name", table: "Ingredients", type: "nvarchar(max)", nullable: false, defaultValue: "", oldClrType: typeof(string), oldType: "nvarchar(max)", oldNullable: true); migrationBuilder.AddColumn( name: "Quantity", table: "Ingredients", type: "int", nullable: false, defaultValue: 0); migrationBuilder.AddColumn( name: "UnitId", table: "Ingredients", type: "uniqueidentifier", nullable: false, defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); migrationBuilder.AlterColumn( name: "Name", table: "Categories", type: "nvarchar(max)", nullable: false, defaultValue: "", oldClrType: typeof(string), oldType: "nvarchar(max)", oldNullable: true); migrationBuilder.CreateTable( name: "Unit", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), Name = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Unit", x => x.Id); }); migrationBuilder.CreateIndex( name: "IX_Ingredients_UnitId", table: "Ingredients", column: "UnitId"); migrationBuilder.AddForeignKey( name: "FK_Ingredients_Unit_UnitId", table: "Ingredients", column: "UnitId", principalTable: "Unit", principalColumn: "Id", onDelete: ReferentialAction.Cascade); } /// protected override void Down(MigrationBuilder migrationBuilder) { if (migrationBuilder == null) { throw new ArgumentNullException(nameof(migrationBuilder)); } migrationBuilder.DropForeignKey( name: "FK_Ingredients_Unit_UnitId", table: "Ingredients"); migrationBuilder.DropTable( name: "Unit"); migrationBuilder.DropIndex( name: "IX_Ingredients_UnitId", table: "Ingredients"); migrationBuilder.DropColumn( name: "Description", table: "Instructions"); migrationBuilder.DropColumn( name: "Number", table: "Instructions"); migrationBuilder.DropColumn( name: "Quantity", table: "Ingredients"); migrationBuilder.DropColumn( name: "UnitId", table: "Ingredients"); migrationBuilder.AlterColumn( name: "Name", table: "Recipes", type: "nvarchar(max)", nullable: true, oldClrType: typeof(string), oldType: "nvarchar(max)"); migrationBuilder.AlterColumn( name: "Difficulty", table: "Recipes", type: "nvarchar(max)", nullable: true, oldClrType: typeof(string), oldType: "nvarchar(max)"); migrationBuilder.AlterColumn( name: "Description", table: "Recipes", type: "nvarchar(max)", nullable: true, oldClrType: typeof(string), oldType: "nvarchar(max)"); migrationBuilder.AddColumn( name: "StepDescription", table: "Instructions", type: "nvarchar(max)", nullable: true); migrationBuilder.AddColumn( name: "StepNumber", table: "Instructions", type: "nvarchar(max)", nullable: true); migrationBuilder.AlterColumn( name: "Name", table: "Ingredients", type: "nvarchar(max)", nullable: true, oldClrType: typeof(string), oldType: "nvarchar(max)"); migrationBuilder.AddColumn( name: "Unit", table: "Ingredients", type: "nvarchar(max)", nullable: true); migrationBuilder.AlterColumn( name: "Name", table: "Categories", type: "nvarchar(max)", nullable: true, oldClrType: typeof(string), oldType: "nvarchar(max)"); } } }