using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Aberwyn.Migrations
{
    public partial class AddLabIngredientModel : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "LabIngredients",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    RecipeLabEntryId = table.Column<int>(type: "int", nullable: false),
                    Quantity = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Item = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_LabIngredients", x => x.Id);
                    table.ForeignKey(
                        name: "FK_LabIngredients_RecipeLabEntries_RecipeLabEntryId",
                        column: x => x.RecipeLabEntryId,
                        principalTable: "RecipeLabEntries",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "LabVersionIngredients",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    RecipeLabVersionId = table.Column<int>(type: "int", nullable: false),
                    Quantity = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Item = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_LabVersionIngredients", x => x.Id);
                    table.ForeignKey(
                        name: "FK_LabVersionIngredients_RecipeLabVersions_RecipeLabVersionId",
                        column: x => x.RecipeLabVersionId,
                        principalTable: "RecipeLabVersions",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateIndex(
                name: "IX_LabIngredients_RecipeLabEntryId",
                table: "LabIngredients",
                column: "RecipeLabEntryId");

            migrationBuilder.CreateIndex(
                name: "IX_LabVersionIngredients_RecipeLabVersionId",
                table: "LabVersionIngredients",
                column: "RecipeLabVersionId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "LabIngredients");

            migrationBuilder.DropTable(
                name: "LabVersionIngredients");
        }
    }
}
