using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace CMSMicroservice.Infrastructure.Persistence.Migrations
{
    /// <inheritdoc />
    public partial class AddWeekDefinitionTable : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "WeekDefinitions",
                schema: "CMS",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    WeekOrder = table.Column<int>(type: "int", nullable: false),
                    DisplayName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    GregorianWeekNumber = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false),
                    PersianWeekNumber = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false),
                    StartDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                    EndDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                    GregorianYear = table.Column<int>(type: "int", nullable: false),
                    PersianYear = table.Column<int>(type: "int", nullable: false),
                    IsActive = table.Column<bool>(type: "bit", nullable: false, defaultValue: true),
                    Created = table.Column<DateTime>(type: "datetime2", nullable: false),
                    CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    LastModified = table.Column<DateTime>(type: "datetime2", nullable: true),
                    LastModifiedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    IsDeleted = table.Column<bool>(type: "bit", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WeekDefinitions", x => x.Id);
                });

            migrationBuilder.CreateIndex(
                name: "IX_WeekDefinition_GregorianWeekNumber",
                schema: "CMS",
                table: "WeekDefinitions",
                column: "GregorianWeekNumber",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_WeekDefinition_GregorianYear",
                schema: "CMS",
                table: "WeekDefinitions",
                column: "GregorianYear");

            migrationBuilder.CreateIndex(
                name: "IX_WeekDefinition_PersianWeekNumber",
                schema: "CMS",
                table: "WeekDefinitions",
                column: "PersianWeekNumber");

            migrationBuilder.CreateIndex(
                name: "IX_WeekDefinition_PersianYear",
                schema: "CMS",
                table: "WeekDefinitions",
                column: "PersianYear");

            migrationBuilder.CreateIndex(
                name: "IX_WeekDefinition_StartDate",
                schema: "CMS",
                table: "WeekDefinitions",
                column: "StartDate");
        }

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