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

namespace YGNT.QuestionLibrary.Migrations
{
    public partial class addResolveTaskQuestion : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "ResolveTaskQuestions",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    QuestionResolveTaskId = table.Column<long>(nullable: false),
                    QuestionOriginId = table.Column<long>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ResolveTaskQuestions", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ResolveTaskQuestions_QuestionOrigins_QuestionOriginId",
                        column: x => x.QuestionOriginId,
                        principalTable: "QuestionOrigins",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_ResolveTaskQuestions_QuestionResolveTasks_QuestionResolveTas~",
                        column: x => x.QuestionResolveTaskId,
                        principalTable: "QuestionResolveTasks",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_ResolveTaskQuestions_QuestionOriginId",
                table: "ResolveTaskQuestions",
                column: "QuestionOriginId");

            migrationBuilder.CreateIndex(
                name: "IX_ResolveTaskQuestions_QuestionResolveTaskId",
                table: "ResolveTaskQuestions",
                column: "QuestionResolveTaskId");
        }

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