using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace RealCV.Infrastructure.Data.Migrations
{
    /// <inheritdoc />
    public partial class AddProcessingStageToCV : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_CVChecks_User_UserId1",
                table: "CVChecks");

            migrationBuilder.DropTable(
                name: "User");

            migrationBuilder.DropIndex(
                name: "IX_CVChecks_UserId1",
                table: "CVChecks");

            migrationBuilder.DropColumn(
                name: "UserId1",
                table: "CVChecks");

            migrationBuilder.AddColumn<string>(
                name: "ProcessingStage",
                table: "CVChecks",
                type: "nvarchar(64)",
                maxLength: 64,
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "AccountsCategory",
                table: "CompanyCache",
                type: "nvarchar(64)",
                maxLength: 64,
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "CompanyType",
                table: "CompanyCache",
                type: "nvarchar(64)",
                maxLength: 64,
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "SicCodesJson",
                table: "CompanyCache",
                type: "nvarchar(256)",
                maxLength: 256,
                nullable: true);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "ProcessingStage",
                table: "CVChecks");

            migrationBuilder.DropColumn(
                name: "AccountsCategory",
                table: "CompanyCache");

            migrationBuilder.DropColumn(
                name: "CompanyType",
                table: "CompanyCache");

            migrationBuilder.DropColumn(
                name: "SicCodesJson",
                table: "CompanyCache");

            migrationBuilder.AddColumn<Guid>(
                name: "UserId1",
                table: "CVChecks",
                type: "uniqueidentifier",
                nullable: true);

            migrationBuilder.CreateTable(
                name: "User",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    ChecksUsedThisMonth = table.Column<int>(type: "int", nullable: false),
                    Email = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
                    Plan = table.Column<int>(type: "int", nullable: false),
                    StripeCustomerId = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_User", x => x.Id);
                });

            migrationBuilder.CreateIndex(
                name: "IX_CVChecks_UserId1",
                table: "CVChecks",
                column: "UserId1");

            migrationBuilder.AddForeignKey(
                name: "FK_CVChecks_User_UserId1",
                table: "CVChecks",
                column: "UserId1",
                principalTable: "User",
                principalColumn: "Id");
        }
    }
}
