using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace esuite.Database.SqlServer.Migrations
{
    /// <inheritdoc />
    public partial class SiteNameNotUnique : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropIndex(
                name: "IX_Sites_OrganisationId_Name",
                schema: "Printer",
                table: "Sites");

            migrationBuilder.AlterColumn<string>(
                name: "Name",
                schema: "Printer",
                table: "Sites",
                type: "nvarchar(max)",
                nullable: false,
                oldClrType: typeof(string),
                oldType: "nvarchar(450)");

            migrationBuilder.CreateIndex(
                name: "IX_Sites_OrganisationId",
                schema: "Printer",
                table: "Sites",
                column: "OrganisationId");

            migrationBuilder.CreateIndex(
                name: "IX_Sites_SigmaId",
                schema: "Printer",
                table: "Sites",
                column: "SigmaId",
                unique: true,
                filter: "[SigmaId] IS NOT NULL");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropIndex(
                name: "IX_Sites_OrganisationId",
                schema: "Printer",
                table: "Sites");

            migrationBuilder.DropIndex(
                name: "IX_Sites_SigmaId",
                schema: "Printer",
                table: "Sites");

            migrationBuilder.AlterColumn<string>(
                name: "Name",
                schema: "Printer",
                table: "Sites",
                type: "nvarchar(450)",
                nullable: false,
                oldClrType: typeof(string),
                oldType: "nvarchar(max)");

            migrationBuilder.CreateIndex(
                name: "IX_Sites_OrganisationId_Name",
                schema: "Printer",
                table: "Sites",
                columns: new[] { "OrganisationId", "Name" },
                unique: true);
        }
    }
}
