using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace TakeoutSaaS.Infrastructure.Migrations
{
    /// <inheritdoc />
    public partial class ExtendProductSpecTemplateForAddonGroups : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropIndex(
                name: "IX_product_spec_templates_TenantId_StoreId_Name",
                table: "product_spec_templates");

            migrationBuilder.AddColumn<string>(
                name: "Description",
                table: "product_spec_templates",
                type: "character varying(256)",
                maxLength: 256,
                nullable: false,
                defaultValue: "",
                comment: "模板描述。");

            migrationBuilder.AddColumn<int>(
                name: "MaxSelect",
                table: "product_spec_templates",
                type: "integer",
                nullable: false,
                defaultValue: 1,
                comment: "最大可选数。");

            migrationBuilder.AddColumn<int>(
                name: "MinSelect",
                table: "product_spec_templates",
                type: "integer",
                nullable: false,
                defaultValue: 0,
                comment: "最小可选数。");

            migrationBuilder.AddColumn<bool>(
                name: "IsEnabled",
                table: "product_spec_template_options",
                type: "boolean",
                nullable: false,
                defaultValue: true,
                comment: "是否启用。");

            migrationBuilder.AddColumn<int>(
                name: "Stock",
                table: "product_spec_template_options",
                type: "integer",
                nullable: false,
                defaultValue: 999,
                comment: "库存数量。");

            migrationBuilder.CreateIndex(
                name: "IX_product_spec_templates_TenantId_StoreId_TemplateType_Name",
                table: "product_spec_templates",
                columns: new[] { "TenantId", "StoreId", "TemplateType", "Name" },
                unique: true);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropIndex(
                name: "IX_product_spec_templates_TenantId_StoreId_TemplateType_Name",
                table: "product_spec_templates");

            migrationBuilder.DropColumn(
                name: "Description",
                table: "product_spec_templates");

            migrationBuilder.DropColumn(
                name: "MaxSelect",
                table: "product_spec_templates");

            migrationBuilder.DropColumn(
                name: "MinSelect",
                table: "product_spec_templates");

            migrationBuilder.DropColumn(
                name: "IsEnabled",
                table: "product_spec_template_options");

            migrationBuilder.DropColumn(
                name: "Stock",
                table: "product_spec_template_options");

            migrationBuilder.CreateIndex(
                name: "IX_product_spec_templates_TenantId_StoreId_Name",
                table: "product_spec_templates",
                columns: new[] { "TenantId", "StoreId", "Name" },
                unique: true);
        }
    }
}
