using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace bitforum.Migrations.DefaultDb
{
    /// <inheritdoc />
    public partial class AddPopupTable : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropIndex(
                name: "IX_Document_IsActive",
                table: "Document");

            migrationBuilder.CreateTable(
                name: "Popup",
                columns: table => new
                {
                    ID = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Subject = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: false),
                    Content = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Link = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: false),
                    StartAt = table.Column<DateTime>(type: "datetime2", nullable: true),
                    EndAt = table.Column<DateTime>(type: "datetime2", nullable: true),
                    Order = table.Column<int>(type: "int", nullable: false),
                    IsActive = table.Column<bool>(type: "bit", nullable: false),
                    Views = table.Column<int>(type: "int", nullable: false),
                    UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Popup", x => x.ID);
                });

            migrationBuilder.CreateIndex(
                name: "IX_Document_IsActive",
                table: "Document",
                column: "IsActive");

            migrationBuilder.CreateIndex(
                name: "IX_Popup_IsActive",
                table: "Popup",
                column: "IsActive");
        }

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

            migrationBuilder.DropIndex(
                name: "IX_Document_IsActive",
                table: "Document");

            migrationBuilder.CreateIndex(
                name: "IX_Document_IsActive",
                table: "Document",
                column: "IsActive",
                unique: true);
        }
    }
}
