using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace PARR.DAL.Migrations
{
    /// <inheritdoc />
    public partial class removeWorks : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_ApplicationsInWorks_Works_WorkId",
                table: "ApplicationsInWorks");

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

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Works",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    TnkId = table.Column<Guid>(type: "uuid", nullable: false),
                    DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
                    DateModified = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
                    EsppId = table.Column<int>(type: "integer", nullable: false),
                    Name = table.Column<string>(type: "text", nullable: false),
                    TemplateNameMask = table.Column<string>(type: "text", nullable: false),
                    TemplateSuffix = table.Column<string>(type: "text", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Works", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Works_Tnks_TnkId",
                        column: x => x.TnkId,
                        principalTable: "Tnks",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_Works_EsppId",
                table: "Works",
                column: "EsppId",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_Works_TnkId",
                table: "Works",
                column: "TnkId");

            migrationBuilder.AddForeignKey(
                name: "FK_ApplicationsInWorks_Works_WorkId",
                table: "ApplicationsInWorks",
                column: "WorkId",
                principalTable: "Works",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
