using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace esuite.Database.SqlServer.Migrations
{
    /// <inheritdoc />
    public partial class SpecificationDomains : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "SpecificationDomains",
                schema: "Printer",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    SpecificationId = table.Column<long>(type: "bigint", nullable: false),
                    DomainId = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SpecificationDomains", x => x.Id);
                    table.UniqueConstraint("AK_SpecificationDomains_SpecificationId_DomainId", x => new { x.SpecificationId, x.DomainId });
                    table.ForeignKey(
                        name: "FK_SpecificationDomains_Domains_DomainId",
                        column: x => x.DomainId,
                        principalSchema: "Domain",
                        principalTable: "Domains",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_SpecificationDomains_Specifications_SpecificationId",
                        column: x => x.SpecificationId,
                        principalSchema: "Printer",
                        principalTable: "Specifications",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_SpecificationDomains_DomainId",
                schema: "Printer",
                table: "SpecificationDomains",
                column: "DomainId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "SpecificationDomains",
                schema: "Printer");
        }
    }
}
