// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using TakeoutSaaS.Infrastructure.Dictionary.Persistence;

#nullable disable

namespace TakeoutSaaS.Infrastructure.Migrations.DictionaryDb
{
    [DbContext(typeof(DictionaryDbContext))]
    [Migration("20251202005247_InitSnowflake_Dictionary")]
    partial class InitSnowflake_Dictionary
    {
        /// <inheritdoc />
        protected override void BuildTargetModel(ModelBuilder modelBuilder)
        {
#pragma warning disable 612, 618
            modelBuilder
                .HasAnnotation("ProductVersion", "10.0.0")
                .HasAnnotation("Relational:MaxIdentifierLength", 63);

            NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);

            modelBuilder.Entity("TakeoutSaaS.Domain.Dictionary.Entities.DictionaryGroup", b =>
                {
                    b.Property<long>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("bigint")
                        .HasComment("实体唯一标识。");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));

                    b.Property<string>("Code")
                        .IsRequired()
                        .HasMaxLength(64)
                        .HasColumnType("character varying(64)")
                        .HasComment("分组编码（唯一）。");

                    b.Property<DateTime>("CreatedAt")
                        .HasColumnType("timestamp with time zone")
                        .HasComment("创建时间（UTC）。");

                    b.Property<long?>("CreatedBy")
                        .HasColumnType("bigint")
                        .HasComment("创建人用户标识，匿名或系统操作时为 null。");

                    b.Property<DateTime?>("DeletedAt")
                        .HasColumnType("timestamp with time zone")
                        .HasComment("软删除时间（UTC），未删除时为 null。");

                    b.Property<long?>("DeletedBy")
                        .HasColumnType("bigint")
                        .HasComment("删除人用户标识（软删除），未删除时为 null。");

                    b.Property<string>("Description")
                        .HasMaxLength(512)
                        .HasColumnType("character varying(512)")
                        .HasComment("描述信息。");

                    b.Property<bool>("IsEnabled")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("boolean")
                        .HasDefaultValue(true)
                        .HasComment("是否启用。");

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasMaxLength(128)
                        .HasColumnType("character varying(128)")
                        .HasComment("分组名称。");

                    b.Property<int>("Scope")
                        .HasColumnType("integer")
                        .HasComment("分组作用域：系统/业务。");

                    b.Property<long>("TenantId")
                        .HasColumnType("bigint")
                        .HasComment("所属租户 ID。");

                    b.Property<DateTime?>("UpdatedAt")
                        .HasColumnType("timestamp with time zone")
                        .HasComment("最近一次更新时间（UTC），从未更新时为 null。");

                    b.Property<long?>("UpdatedBy")
                        .HasColumnType("bigint")
                        .HasComment("最后更新人用户标识，匿名或系统操作时为 null。");

                    b.HasKey("Id");

                    b.HasIndex("TenantId");

                    b.HasIndex("TenantId", "Code")
                        .IsUnique();

                    b.ToTable("dictionary_groups", null, t =>
                        {
                            t.HasComment("参数字典分组（系统参数、业务参数）。");
                        });
                });

            modelBuilder.Entity("TakeoutSaaS.Domain.Dictionary.Entities.DictionaryItem", b =>
                {
                    b.Property<long>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("bigint")
                        .HasComment("实体唯一标识。");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));

                    b.Property<DateTime>("CreatedAt")
                        .HasColumnType("timestamp with time zone")
                        .HasComment("创建时间（UTC）。");

                    b.Property<long?>("CreatedBy")
                        .HasColumnType("bigint")
                        .HasComment("创建人用户标识，匿名或系统操作时为 null。");

                    b.Property<DateTime?>("DeletedAt")
                        .HasColumnType("timestamp with time zone")
                        .HasComment("软删除时间（UTC），未删除时为 null。");

                    b.Property<long?>("DeletedBy")
                        .HasColumnType("bigint")
                        .HasComment("删除人用户标识（软删除），未删除时为 null。");

                    b.Property<string>("Description")
                        .HasMaxLength(512)
                        .HasColumnType("character varying(512)")
                        .HasComment("描述信息。");

                    b.Property<long>("GroupId")
                        .HasColumnType("bigint")
                        .HasComment("关联分组 ID。");

                    b.Property<bool>("IsDefault")
                        .HasColumnType("boolean")
                        .HasComment("是否默认项。");

                    b.Property<bool>("IsEnabled")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("boolean")
                        .HasDefaultValue(true)
                        .HasComment("是否启用。");

                    b.Property<string>("Key")
                        .IsRequired()
                        .HasMaxLength(64)
                        .HasColumnType("character varying(64)")
                        .HasComment("字典项键。");

                    b.Property<int>("SortOrder")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer")
                        .HasDefaultValue(100)
                        .HasComment("排序值，越小越靠前。");

                    b.Property<long>("TenantId")
                        .HasColumnType("bigint")
                        .HasComment("所属租户 ID。");

                    b.Property<DateTime?>("UpdatedAt")
                        .HasColumnType("timestamp with time zone")
                        .HasComment("最近一次更新时间（UTC），从未更新时为 null。");

                    b.Property<long?>("UpdatedBy")
                        .HasColumnType("bigint")
                        .HasComment("最后更新人用户标识，匿名或系统操作时为 null。");

                    b.Property<string>("Value")
                        .IsRequired()
                        .HasMaxLength(256)
                        .HasColumnType("character varying(256)")
                        .HasComment("字典项值。");

                    b.HasKey("Id");

                    b.HasIndex("TenantId");

                    b.HasIndex("GroupId", "Key")
                        .IsUnique();

                    b.ToTable("dictionary_items", null, t =>
                        {
                            t.HasComment("参数字典项。");
                        });
                });

            modelBuilder.Entity("TakeoutSaaS.Domain.Dictionary.Entities.DictionaryItem", b =>
                {
                    b.HasOne("TakeoutSaaS.Domain.Dictionary.Entities.DictionaryGroup", "Group")
                        .WithMany("Items")
                        .HasForeignKey("GroupId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("Group");
                });

            modelBuilder.Entity("TakeoutSaaS.Domain.Dictionary.Entities.DictionaryGroup", b =>
                {
                    b.Navigation("Items");
                });
#pragma warning restore 612, 618
        }
    }
}
