using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable
namespace Hcs.WebApp.Data.Hcs.Migrations
{
    /// <inheritdoc />
    public partial class AddHouseEntity : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Houses",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    FiasId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    ThirdPartyId = table.Column<int>(type: "int", nullable: false),
                    IsMkd = table.Column<bool>(type: "bit", nullable: false),
                    IsZhd = table.Column<bool>(type: "bit", nullable: false),
                    SyncedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
                    LastSyncOperationId = table.Column<int>(type: "int", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Houses", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Houses_Operations_LastSyncOperationId",
                        column: x => x.LastSyncOperationId,
                        principalTable: "Operations",
                        principalColumn: "Id");
                });

            migrationBuilder.CreateIndex(
                name: "IX_Houses_FiasId",
                table: "Houses",
                column: "FiasId",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_Houses_LastSyncOperationId",
                table: "Houses",
                column: "LastSyncOperationId");
        }

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