using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace TakeoutSaaS.Infrastructure.Migrations.DictionaryDb
{
///
public partial class AddSystemParametersTable : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "system_parameters",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false, comment: "实体唯一标识。")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Key = table.Column(type: "character varying(128)", maxLength: 128, nullable: false, comment: "参数键,租户内唯一。"),
Value = table.Column(type: "text", nullable: false, comment: "参数值,支持文本或 JSON。"),
Description = table.Column(type: "character varying(512)", maxLength: 512, nullable: true, comment: "描述信息。"),
SortOrder = table.Column(type: "integer", nullable: false, defaultValue: 100, comment: "排序值,越小越靠前。"),
IsEnabled = table.Column(type: "boolean", nullable: false, defaultValue: true, comment: "是否启用。"),
CreatedAt = table.Column(type: "timestamp with time zone", nullable: false, comment: "创建时间(UTC)。"),
UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true, comment: "最近一次更新时间(UTC),从未更新时为 null。"),
DeletedAt = table.Column(type: "timestamp with time zone", nullable: true, comment: "软删除时间(UTC),未删除时为 null。"),
CreatedBy = table.Column(type: "bigint", nullable: true, comment: "创建人用户标识,匿名或系统操作时为 null。"),
UpdatedBy = table.Column(type: "bigint", nullable: true, comment: "最后更新人用户标识,匿名或系统操作时为 null。"),
DeletedBy = table.Column(type: "bigint", nullable: true, comment: "删除人用户标识(软删除),未删除时为 null。"),
TenantId = table.Column(type: "bigint", nullable: false, comment: "所属租户 ID。")
},
constraints: table =>
{
table.PrimaryKey("PK_system_parameters", x => x.Id);
},
comment: "系统参数实体:支持按租户维护的键值型配置。");
migrationBuilder.CreateIndex(
name: "IX_system_parameters_TenantId",
table: "system_parameters",
column: "TenantId");
migrationBuilder.CreateIndex(
name: "IX_system_parameters_TenantId_Key",
table: "system_parameters",
columns: new[] { "TenantId", "Key" },
unique: true);
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "system_parameters");
}
}
}