using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

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

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

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

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

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

            migrationBuilder.CreateIndex(
                name: "IX_Specifications_SiteId_Name",
                schema: "Printer",
                table: "Specifications",
                columns: new[] { "SiteId", "Name" },
                unique: true);

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

            migrationBuilder.CreateIndex(
                name: "IX_Organisations_Name",
                schema: "Printer",
                table: "Organisations",
                column: "Name",
                unique: true);
        }

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

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

            migrationBuilder.DropIndex(
                name: "IX_Organisations_Name",
                schema: "Printer",
                table: "Organisations");

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

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

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

            migrationBuilder.CreateIndex(
                name: "IX_Specifications_SiteId",
                schema: "Printer",
                table: "Specifications",
                column: "SiteId");

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