using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace PARR.DAL.Migrations
{
    /// <inheritdoc />
    public partial class tblTemplateRenamePendings : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.EnsureSchema(
                name: "template");

            migrationBuilder.CreateTable(
                name: "TemplateRenamePendings",
                schema: "template",
                columns: table => new
                {
                    TemplateId = table.Column<Guid>(type: "uuid", nullable: false),
                    DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
                    OldName = table.Column<string>(type: "text", nullable: false, comment: "Старое имя шаблона")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TemplateRenamePendings", x => x.TemplateId);
                    table.ForeignKey(
                        name: "FK_TemplateRenamePendings_Templates_TemplateId",
                        column: x => x.TemplateId,
                        principalTable: "Templates",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "Шаблоны находящиеся в процессе переименования");

            migrationBuilder.CreateIndex(
                name: "IX_TemplateRenamePendings_OldName",
                schema: "template",
                table: "TemplateRenamePendings",
                column: "OldName",
                unique: true);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "TemplateRenamePendings",
                schema: "template");
        }
    }
}
