using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace ZB.MOM.WW.OtOpcUa.Configuration.Migrations
{
    /// <inheritdoc />
    public partial class AddDriverInstanceResilienceStatus : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "DriverInstanceResilienceStatus",
                columns: table => new
                {
                    DriverInstanceId = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
                    HostName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
                    LastCircuitBreakerOpenUtc = table.Column<DateTime>(type: "datetime2(3)", nullable: true),
                    ConsecutiveFailures = table.Column<int>(type: "int", nullable: false),
                    CurrentBulkheadDepth = table.Column<int>(type: "int", nullable: false),
                    LastRecycleUtc = table.Column<DateTime>(type: "datetime2(3)", nullable: true),
                    BaselineFootprintBytes = table.Column<long>(type: "bigint", nullable: false),
                    CurrentFootprintBytes = table.Column<long>(type: "bigint", nullable: false),
                    LastSampledUtc = table.Column<DateTime>(type: "datetime2(3)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_DriverInstanceResilienceStatus", x => new { x.DriverInstanceId, x.HostName });
                });

            migrationBuilder.CreateIndex(
                name: "IX_DriverResilience_LastSampled",
                table: "DriverInstanceResilienceStatus",
                column: "LastSampledUtc");
        }

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