using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace ZB.MOM.WW.OtOpcUa.Configuration.Migrations
{
    /// <inheritdoc />
    public partial class DropScriptedAlarmStateTable : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "ScriptedAlarmState");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "ScriptedAlarmState",
                columns: table => new
                {
                    ScriptedAlarmId = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
                    AckedState = table.Column<string>(type: "nvarchar(16)", maxLength: 16, nullable: false),
                    CommentsJson = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    ConfirmedState = table.Column<string>(type: "nvarchar(16)", maxLength: 16, nullable: false),
                    EnabledState = table.Column<string>(type: "nvarchar(16)", maxLength: 16, nullable: false),
                    LastAckComment = table.Column<string>(type: "nvarchar(1024)", maxLength: 1024, nullable: true),
                    LastAckUser = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: true),
                    LastAckUtc = table.Column<DateTime>(type: "datetime2(3)", nullable: true),
                    LastConfirmComment = table.Column<string>(type: "nvarchar(1024)", maxLength: 1024, nullable: true),
                    LastConfirmUser = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: true),
                    LastConfirmUtc = table.Column<DateTime>(type: "datetime2(3)", nullable: true),
                    ShelvingExpiresUtc = table.Column<DateTime>(type: "datetime2(3)", nullable: true),
                    ShelvingState = table.Column<string>(type: "nvarchar(16)", maxLength: 16, nullable: false),
                    UpdatedAtUtc = table.Column<DateTime>(type: "datetime2(3)", nullable: false, defaultValueSql: "SYSUTCDATETIME()")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ScriptedAlarmState", x => x.ScriptedAlarmId);
                    table.CheckConstraint("CK_ScriptedAlarmState_CommentsJson_IsJson", "ISJSON(CommentsJson) = 1");
                });
        }
    }
}
