using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace WorkFlowCheck.DL.Migrations
{
    /// <inheritdoc />
    public partial class Extend005 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "NumberGeneratorTemplate",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    ShortName = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Prefix = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    PrefixSeparator = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    DigitFormat = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    SuffixSeparator = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Suffix = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    CurrentNumber = table.Column<int>(type: "int", nullable: false),
                    LastGeneratedNumber = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    GenerateType = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_NumberGeneratorTemplate", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "NumberGeneratorTemplateDate",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    NumberGeneratorTemplateId = table.Column<int>(type: "int", nullable: false),
                    Year = table.Column<int>(type: "int", nullable: false),
                    Month = table.Column<int>(type: "int", nullable: true),
                    CurrentNumber = table.Column<int>(type: "int", nullable: false),
                    LastGeneratedNumber = table.Column<string>(type: "nvarchar(max)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_NumberGeneratorTemplateDate", x => x.Id);
                    table.ForeignKey(
                        name: "FK_NumberGeneratorTemplateDate_NumberGeneratorTemplate_NumberGeneratorTemplateId",
                        column: x => x.NumberGeneratorTemplateId,
                        principalTable: "NumberGeneratorTemplate",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.InsertData(
                table: "NumberGeneratorTemplate",
                columns: new[] { "Id", "CurrentNumber", "DigitFormat", "GenerateType", "LastGeneratedNumber", "Prefix", "PrefixSeparator", "ShortName", "Suffix", "SuffixSeparator" },
                values: new object[] { 1, 0, "D4", 0, "", "CHK", "-", "Ellenőrzési dokumentum sorszámozása", "", "-" });

            migrationBuilder.UpdateData(
                table: "Users",
                keyColumn: "Id",
                keyValue: 1,
                columns: new[] { "CreatedAt", "LastModAt" },
                values: new object[] { new DateTime(2025, 3, 19, 13, 25, 30, 814, DateTimeKind.Utc).AddTicks(9821), new DateTime(2025, 3, 19, 13, 25, 30, 814, DateTimeKind.Utc).AddTicks(9825) });

            migrationBuilder.UpdateData(
                table: "Users",
                keyColumn: "Id",
                keyValue: 2,
                columns: new[] { "CreatedAt", "LastModAt" },
                values: new object[] { new DateTime(2025, 3, 19, 13, 25, 30, 829, DateTimeKind.Utc).AddTicks(5779), new DateTime(2025, 3, 19, 13, 25, 30, 829, DateTimeKind.Utc).AddTicks(5783) });

            migrationBuilder.CreateIndex(
                name: "IX_NumberGeneratorTemplateDate_NumberGeneratorTemplateId",
                table: "NumberGeneratorTemplateDate",
                column: "NumberGeneratorTemplateId");
        }

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

            migrationBuilder.DropTable(
                name: "NumberGeneratorTemplate");

            migrationBuilder.UpdateData(
                table: "Users",
                keyColumn: "Id",
                keyValue: 1,
                columns: new[] { "CreatedAt", "LastModAt" },
                values: new object[] { new DateTime(2025, 3, 18, 10, 48, 13, 634, DateTimeKind.Utc).AddTicks(7867), new DateTime(2025, 3, 18, 10, 48, 13, 634, DateTimeKind.Utc).AddTicks(7870) });

            migrationBuilder.UpdateData(
                table: "Users",
                keyColumn: "Id",
                keyValue: 2,
                columns: new[] { "CreatedAt", "LastModAt" },
                values: new object[] { new DateTime(2025, 3, 18, 10, 48, 13, 645, DateTimeKind.Utc).AddTicks(9210), new DateTime(2025, 3, 18, 10, 48, 13, 645, DateTimeKind.Utc).AddTicks(9212) });
        }
    }
}
