using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace WorkFlowCheck.DL.Migrations
{
    /// <inheritdoc />
    public partial class Extend001 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_CheckListTemplateRow_CheckListHeader_CheckListHeaderId",
                table: "CheckListTemplateRow");

            migrationBuilder.DropIndex(
                name: "IX_CheckListTemplateRow_CheckListHeaderId",
                table: "CheckListTemplateRow");

            migrationBuilder.DropColumn(
                name: "CheckListHeaderId",
                table: "CheckListTemplateRow");

            migrationBuilder.CreateTable(
                name: "CheckListRow",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    CheckListHeaderId = table.Column<int>(type: "int", nullable: false),
                    CheckListTemplateRowId = table.Column<int>(type: "int", nullable: false),
                    Answer = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    LastModAt = table.Column<DateTime>(type: "datetime2", nullable: false),
                    LastModBy = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
                    CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    IsDeleted = table.Column<bool>(type: "bit", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CheckListRow", x => x.Id);
                    table.ForeignKey(
                        name: "FK_CheckListRow_CheckListHeader_CheckListHeaderId",
                        column: x => x.CheckListHeaderId,
                        principalTable: "CheckListHeader",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_CheckListRow_CheckListTemplateRow_CheckListTemplateRowId",
                        column: x => x.CheckListTemplateRowId,
                        principalTable: "CheckListTemplateRow",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.UpdateData(
                table: "Users",
                keyColumn: "Id",
                keyValue: 1,
                columns: new[] { "CreatedAt", "LastModAt" },
                values: new object[] { new DateTime(2025, 2, 19, 11, 59, 47, 916, DateTimeKind.Utc).AddTicks(948), new DateTime(2025, 2, 19, 11, 59, 47, 916, DateTimeKind.Utc).AddTicks(951) });

            migrationBuilder.UpdateData(
                table: "Users",
                keyColumn: "Id",
                keyValue: 2,
                columns: new[] { "CreatedAt", "LastModAt" },
                values: new object[] { new DateTime(2025, 2, 19, 11, 59, 47, 927, DateTimeKind.Utc).AddTicks(3684), new DateTime(2025, 2, 19, 11, 59, 47, 927, DateTimeKind.Utc).AddTicks(3685) });

            migrationBuilder.CreateIndex(
                name: "IX_CheckListRow_CheckListHeaderId",
                table: "CheckListRow",
                column: "CheckListHeaderId");

            migrationBuilder.CreateIndex(
                name: "IX_CheckListRow_CheckListTemplateRowId",
                table: "CheckListRow",
                column: "CheckListTemplateRowId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "CheckListRow");

            migrationBuilder.AddColumn<int>(
                name: "CheckListHeaderId",
                table: "CheckListTemplateRow",
                type: "int",
                nullable: true);

            migrationBuilder.UpdateData(
                table: "Users",
                keyColumn: "Id",
                keyValue: 1,
                columns: new[] { "CreatedAt", "LastModAt" },
                values: new object[] { new DateTime(2025, 2, 19, 11, 10, 8, 377, DateTimeKind.Utc).AddTicks(26), new DateTime(2025, 2, 19, 11, 10, 8, 377, DateTimeKind.Utc).AddTicks(29) });

            migrationBuilder.UpdateData(
                table: "Users",
                keyColumn: "Id",
                keyValue: 2,
                columns: new[] { "CreatedAt", "LastModAt" },
                values: new object[] { new DateTime(2025, 2, 19, 11, 10, 8, 389, DateTimeKind.Utc).AddTicks(2814), new DateTime(2025, 2, 19, 11, 10, 8, 389, DateTimeKind.Utc).AddTicks(2817) });

            migrationBuilder.CreateIndex(
                name: "IX_CheckListTemplateRow_CheckListHeaderId",
                table: "CheckListTemplateRow",
                column: "CheckListHeaderId");

            migrationBuilder.AddForeignKey(
                name: "FK_CheckListTemplateRow_CheckListHeader_CheckListHeaderId",
                table: "CheckListTemplateRow",
                column: "CheckListHeaderId",
                principalTable: "CheckListHeader",
                principalColumn: "Id");
        }
    }
}
