using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Jiaowu.Api.Infrastructure.Persistence.Migrations.MySql
{
    /// <inheritdoc />
    public partial class BindCentralizedExperimentProjectsToSchedules : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<Guid>(
                name: "ScheduleEntryId",
                table: "ExperimentProjects",
                type: "char(36)",
                nullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_ExperimentProjects_ScheduleEntryId",
                table: "ExperimentProjects",
                column: "ScheduleEntryId");

            migrationBuilder.AddForeignKey(
                name: "FK_ExperimentProjects_ScheduleEntries_ScheduleEntryId",
                table: "ExperimentProjects",
                column: "ScheduleEntryId",
                principalTable: "ScheduleEntries",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_ExperimentProjects_ScheduleEntries_ScheduleEntryId",
                table: "ExperimentProjects");

            migrationBuilder.DropIndex(
                name: "IX_ExperimentProjects_ScheduleEntryId",
                table: "ExperimentProjects");

            migrationBuilder.DropColumn(
                name: "ScheduleEntryId",
                table: "ExperimentProjects");
        }
    }
}
