using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Apollinare.Infrastructure.Migrations
{
    /// <inheritdoc />
    public partial class AddAutoCodeSystem : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "AutoCodes",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    EntityCode = table.Column<string>(type: "TEXT", nullable: false),
                    EntityName = table.Column<string>(type: "TEXT", nullable: false),
                    Prefix = table.Column<string>(type: "TEXT", nullable: true),
                    Pattern = table.Column<string>(type: "TEXT", nullable: false),
                    LastSequence = table.Column<long>(type: "INTEGER", nullable: false),
                    ResetSequenceYearly = table.Column<bool>(type: "INTEGER", nullable: false),
                    ResetSequenceMonthly = table.Column<bool>(type: "INTEGER", nullable: false),
                    LastResetYear = table.Column<int>(type: "INTEGER", nullable: true),
                    LastResetMonth = table.Column<int>(type: "INTEGER", nullable: true),
                    IsEnabled = table.Column<bool>(type: "INTEGER", nullable: false),
                    IsReadOnly = table.Column<bool>(type: "INTEGER", nullable: false),
                    ModuleCode = table.Column<string>(type: "TEXT", nullable: true),
                    Description = table.Column<string>(type: "TEXT", nullable: true),
                    SortOrder = table.Column<int>(type: "INTEGER", nullable: false),
                    CreatedAt = table.Column<DateTime>(type: "TEXT", nullable: true),
                    CreatedBy = table.Column<string>(type: "TEXT", nullable: true),
                    UpdatedAt = table.Column<DateTime>(type: "TEXT", nullable: true),
                    UpdatedBy = table.Column<string>(type: "TEXT", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AutoCodes", x => x.Id);
                });

            migrationBuilder.CreateIndex(
                name: "IX_AutoCodes_EntityCode",
                table: "AutoCodes",
                column: "EntityCode",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_AutoCodes_ModuleCode",
                table: "AutoCodes",
                column: "ModuleCode");
        }

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