using Microsoft.EntityFrameworkCore.Migrations; using MySql.EntityFrameworkCore.Metadata; #nullable disable namespace API.Migrations { /// public partial class MadeAmountAndUnitNullable : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Recipes_PrefereredRecipes_PrefereredRecipesId", table: "Recipes"); migrationBuilder.DropTable( name: "PrefereredRecipes"); migrationBuilder.DropIndex( name: "IX_Recipes_PrefereredRecipesId", table: "Recipes"); migrationBuilder.DropColumn( name: "Directions", table: "Recipes"); migrationBuilder.DropColumn( name: "PrefereredRecipesId", table: "Recipes"); migrationBuilder.AlterColumn( name: "Unit", table: "ShoppingList", type: "longtext", nullable: true, oldClrType: typeof(string), oldType: "longtext"); migrationBuilder.AlterColumn( name: "Amount", table: "ShoppingList", type: "double", nullable: true, oldClrType: typeof(double), oldType: "double"); migrationBuilder.AlterColumn( name: "Unit", table: "Ingredient", type: "longtext", nullable: true, oldClrType: typeof(string), oldType: "longtext"); migrationBuilder.AlterColumn( name: "Amount", table: "Ingredient", type: "double", nullable: true, oldClrType: typeof(int), oldType: "int"); migrationBuilder.CreateTable( name: "Directions", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), Instruktions = table.Column(type: "longtext", nullable: false), RecipeId = table.Column(type: "int", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Directions", x => x.Id); table.ForeignKey( name: "FK_Directions_Recipes_RecipeId", column: x => x.RecipeId, principalTable: "Recipes", principalColumn: "Id"); }) .Annotation("MySQL:Charset", "utf8mb4"); migrationBuilder.CreateIndex( name: "IX_Directions_RecipeId", table: "Directions", column: "RecipeId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Directions"); migrationBuilder.AlterColumn( name: "Unit", table: "ShoppingList", type: "longtext", nullable: false, defaultValue: "", oldClrType: typeof(string), oldType: "longtext", oldNullable: true); migrationBuilder.AlterColumn( name: "Amount", table: "ShoppingList", type: "double", nullable: false, defaultValue: 0.0, oldClrType: typeof(double), oldType: "double", oldNullable: true); migrationBuilder.AddColumn( name: "Directions", table: "Recipes", type: "longtext", nullable: false); migrationBuilder.AddColumn( name: "PrefereredRecipesId", table: "Recipes", type: "int", nullable: true); migrationBuilder.AlterColumn( name: "Unit", table: "Ingredient", type: "longtext", nullable: false, defaultValue: "", oldClrType: typeof(string), oldType: "longtext", oldNullable: true); migrationBuilder.AlterColumn( name: "Amount", table: "Ingredient", type: "int", nullable: false, defaultValue: 0, oldClrType: typeof(double), oldType: "double", oldNullable: true); migrationBuilder.CreateTable( name: "PrefereredRecipes", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn) }, constraints: table => { table.PrimaryKey("PK_PrefereredRecipes", x => x.Id); }) .Annotation("MySQL:Charset", "utf8mb4"); migrationBuilder.CreateIndex( name: "IX_Recipes_PrefereredRecipesId", table: "Recipes", column: "PrefereredRecipesId"); migrationBuilder.AddForeignKey( name: "FK_Recipes_PrefereredRecipes_PrefereredRecipesId", table: "Recipes", column: "PrefereredRecipesId", principalTable: "PrefereredRecipes", principalColumn: "Id"); } } }