using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Meezi.Infrastructure.Data.Migrations
{
    /// <inheritdoc />
    public partial class EmployeePhoneUniquePerCafe : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_MenuItemIngredients_Cafes_CafeId",
                table: "MenuItemIngredients");

            migrationBuilder.DropIndex(
                name: "IX_Employees_CafeId_Phone",
                table: "Employees");

            migrationBuilder.CreateIndex(
                name: "IX_Employees_CafeId_Phone",
                table: "Employees",
                columns: new[] { "CafeId", "Phone" },
                unique: true,
                filter: "\"DeletedAt\" IS NULL");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropIndex(
                name: "IX_Employees_CafeId_Phone",
                table: "Employees");

            migrationBuilder.CreateIndex(
                name: "IX_Employees_CafeId_Phone",
                table: "Employees",
                columns: new[] { "CafeId", "Phone" });

            migrationBuilder.AddForeignKey(
                name: "FK_MenuItemIngredients_Cafes_CafeId",
                table: "MenuItemIngredients",
                column: "CafeId",
                principalTable: "Cafes",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
