using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

namespace YGNT.QuestionLibrary.Migrations
{
    public partial class addpaperProduceResult : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "AnswerFileId",
                table: "Papers");

            migrationBuilder.DropColumn(
                name: "AnswerSheetFileId",
                table: "Papers");

            migrationBuilder.DropColumn(
                name: "FileId",
                table: "Papers");

            migrationBuilder.DropColumn(
                name: "FullPaperFileId",
                table: "Papers");

            migrationBuilder.DropColumn(
                name: "ProducePath",
                table: "Papers");

            migrationBuilder.CreateTable(
                name: "PaperProduceResults",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    PaperId = table.Column<int>(nullable: false),
                    PaperProduceTaskId = table.Column<long>(nullable: false),
                    ProducePath = table.Column<string>(nullable: true),
                    FileId = table.Column<Guid>(nullable: true),
                    FullPaperFileId = table.Column<Guid>(nullable: true),
                    AnswerFileId = table.Column<Guid>(nullable: true),
                    AnswerSheetFileId = table.Column<Guid>(nullable: true),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PaperProduceResults", x => x.Id);
                    table.ForeignKey(
                        name: "FK_PaperProduceResults_Papers_PaperId",
                        column: x => x.PaperId,
                        principalTable: "Papers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_PaperProduceResults_PaperProduceTasks_PaperProduceTaskId",
                        column: x => x.PaperProduceTaskId,
                        principalTable: "PaperProduceTasks",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_PaperProduceResults_PaperId",
                table: "PaperProduceResults",
                column: "PaperId");

            migrationBuilder.CreateIndex(
                name: "IX_PaperProduceResults_PaperProduceTaskId",
                table: "PaperProduceResults",
                column: "PaperProduceTaskId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "PaperProduceResults");

            migrationBuilder.AddColumn<Guid>(
                name: "AnswerFileId",
                table: "Papers",
                type: "char(36)",
                nullable: true);

            migrationBuilder.AddColumn<Guid>(
                name: "AnswerSheetFileId",
                table: "Papers",
                type: "char(36)",
                nullable: true);

            migrationBuilder.AddColumn<Guid>(
                name: "FileId",
                table: "Papers",
                type: "char(36)",
                nullable: true);

            migrationBuilder.AddColumn<Guid>(
                name: "FullPaperFileId",
                table: "Papers",
                type: "char(36)",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "ProducePath",
                table: "Papers",
                type: "longtext CHARACTER SET utf8mb4",
                nullable: true);
        }
    }
}
