using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional

namespace PARR.DAL.Migrations
{
    /// <inheritdoc />
    public partial class tblJobGroupTypeCreate : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.RenameColumn(
                name: "isParentRelationships",
                schema: "job",
                table: "Jobs",
                newName: "IsParentRelationships");

            migrationBuilder.AddColumn<Guid>(
                name: "GroupTypeId",
                schema: "job",
                table: "Groups",
                type: "uuid",
                nullable: false,
                defaultValue: new Guid("4FA62E79-86BB-47C2-BE1A-72A716A170FA"));

            migrationBuilder.CreateTable(
                name: "GroupTypes",
                schema: "job",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
                    Code = table.Column<int>(type: "integer", nullable: false),
                    Name = table.Column<string>(type: "text", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_GroupTypes", x => x.Id);
                },
                comment: "Таблица типов групп работ");

            migrationBuilder.InsertData(
                schema: "job",
                table: "GroupTypes",
                columns: new[] { "Id", "Code", "DateCreated", "Name" },
                values: new object[,]
                {
                    { new Guid("318625e5-f833-436a-99df-2a382a1e71c7"), 2, new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), "Group" },
                    { new Guid("4fa62e79-86bb-47c2-be1a-72a716a170fa"), 0, new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), "Simple" },
                    { new Guid("6ec58b1a-5c40-47b9-b036-4fa490e8d503"), 1, new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), "Umbrella" }
                });

            migrationBuilder.CreateIndex(
                name: "IX_Groups_GroupTypeId",
                schema: "job",
                table: "Groups",
                column: "GroupTypeId");

            migrationBuilder.AddForeignKey(
                name: "FK_Groups_GroupTypes_GroupTypeId",
                schema: "job",
                table: "Groups",
                column: "GroupTypeId",
                principalSchema: "job",
                principalTable: "GroupTypes",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Groups_GroupTypes_GroupTypeId",
                schema: "job",
                table: "Groups");

            migrationBuilder.DropTable(
                name: "GroupTypes",
                schema: "job");

            migrationBuilder.DropIndex(
                name: "IX_Groups_GroupTypeId",
                schema: "job",
                table: "Groups");

            migrationBuilder.DropColumn(
                name: "GroupTypeId",
                schema: "job",
                table: "Groups");

            migrationBuilder.RenameColumn(
                name: "IsParentRelationships",
                schema: "job",
                table: "Jobs",
                newName: "isParentRelationships");
        }
    }
}
