Files
TakeoutSaaS.AdminApi/src/Infrastructure/TakeoutSaaS.Infrastructure/Migrations/20251205113018_AddTenantVerificationProfile.cs

545 lines
36 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace TakeoutSaaS.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddTenantVerificationProfile : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<long>(
name: "StoreId",
table: "queue_tickets",
type: "bigint",
nullable: false,
comment: "获取或设置所属门店 ID。",
oldClrType: typeof(long),
oldType: "bigint");
migrationBuilder.AddColumn<int>(
name: "BatchConsumeStrategy",
table: "inventory_items",
type: "integer",
nullable: false,
defaultValue: 0,
comment: "批次扣减策略。");
migrationBuilder.AddColumn<bool>(
name: "IsPresale",
table: "inventory_items",
type: "boolean",
nullable: false,
defaultValue: false,
comment: "是否预售商品。");
migrationBuilder.AddColumn<bool>(
name: "IsSoldOut",
table: "inventory_items",
type: "boolean",
nullable: false,
defaultValue: false,
comment: "是否标记售罄。");
migrationBuilder.AddColumn<int>(
name: "MaxQuantityPerOrder",
table: "inventory_items",
type: "integer",
nullable: true,
comment: "单品限购(覆盖商品级 MaxQuantityPerOrder。");
migrationBuilder.AddColumn<int>(
name: "PresaleCapacity",
table: "inventory_items",
type: "integer",
nullable: true,
comment: "预售名额(上限)。");
migrationBuilder.AddColumn<DateTime>(
name: "PresaleEndTime",
table: "inventory_items",
type: "timestamp with time zone",
nullable: true,
comment: "预售结束时间UTC。");
migrationBuilder.AddColumn<int>(
name: "PresaleLocked",
table: "inventory_items",
type: "integer",
nullable: false,
defaultValue: 0,
comment: "当前预售已锁定数量。");
migrationBuilder.AddColumn<DateTime>(
name: "PresaleStartTime",
table: "inventory_items",
type: "timestamp with time zone",
nullable: true,
comment: "预售开始时间UTC。");
migrationBuilder.AddColumn<byte[]>(
name: "RowVersion",
table: "inventory_items",
type: "bytea",
rowVersion: true,
nullable: false,
defaultValue: new byte[0],
comment: "并发控制字段。");
migrationBuilder.AddColumn<byte[]>(
name: "RowVersion",
table: "inventory_batches",
type: "bytea",
rowVersion: true,
nullable: false,
defaultValue: new byte[0],
comment: "并发控制字段。");
migrationBuilder.AlterColumn<long>(
name: "OrderId",
table: "delivery_orders",
type: "bigint",
nullable: false,
comment: "获取或设置关联订单 ID。",
oldClrType: typeof(long),
oldType: "bigint");
migrationBuilder.CreateTable(
name: "inventory_lock_records",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false, comment: "实体唯一标识。")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
StoreId = table.Column<long>(type: "bigint", nullable: false, comment: "门店 ID。"),
ProductSkuId = table.Column<long>(type: "bigint", nullable: false, comment: "SKU ID。"),
Quantity = table.Column<int>(type: "integer", nullable: false, comment: "锁定数量。"),
IsPresale = table.Column<bool>(type: "boolean", nullable: false, comment: "是否预售锁定。"),
IdempotencyKey = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false, comment: "幂等键。"),
ExpiresAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "过期时间UTC。"),
Status = table.Column<int>(type: "integer", nullable: false, comment: "锁定状态。"),
RowVersion = table.Column<byte[]>(type: "bytea", rowVersion: true, nullable: false, comment: "并发控制字段。"),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, comment: "创建时间UTC。"),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "最近一次更新时间UTC从未更新时为 null。"),
DeletedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "软删除时间UTC未删除时为 null。"),
CreatedBy = table.Column<long>(type: "bigint", nullable: true, comment: "创建人用户标识,匿名或系统操作时为 null。"),
UpdatedBy = table.Column<long>(type: "bigint", nullable: true, comment: "最后更新人用户标识,匿名或系统操作时为 null。"),
DeletedBy = table.Column<long>(type: "bigint", nullable: true, comment: "删除人用户标识(软删除),未删除时为 null。"),
TenantId = table.Column<long>(type: "bigint", nullable: false, comment: "所属租户 ID。")
},
constraints: table =>
{
table.PrimaryKey("PK_inventory_lock_records", x => x.Id);
},
comment: "库存锁定记录。");
migrationBuilder.CreateTable(
name: "merchant_audit_logs",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false, comment: "实体唯一标识。")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
MerchantId = table.Column<long>(type: "bigint", nullable: false, comment: "商户标识。"),
Action = table.Column<int>(type: "integer", nullable: false, comment: "动作类型。"),
Title = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false, comment: "标题。"),
Description = table.Column<string>(type: "character varying(1024)", maxLength: 1024, nullable: true, comment: "详情描述。"),
OperatorId = table.Column<long>(type: "bigint", nullable: true, comment: "操作人 ID。"),
OperatorName = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true, comment: "操作人名称。"),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, comment: "创建时间UTC。"),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "最近一次更新时间UTC从未更新时为 null。"),
DeletedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "软删除时间UTC未删除时为 null。"),
CreatedBy = table.Column<long>(type: "bigint", nullable: true, comment: "创建人用户标识,匿名或系统操作时为 null。"),
UpdatedBy = table.Column<long>(type: "bigint", nullable: true, comment: "最后更新人用户标识,匿名或系统操作时为 null。"),
DeletedBy = table.Column<long>(type: "bigint", nullable: true, comment: "删除人用户标识(软删除),未删除时为 null。"),
TenantId = table.Column<long>(type: "bigint", nullable: false, comment: "所属租户 ID。")
},
constraints: table =>
{
table.PrimaryKey("PK_merchant_audit_logs", x => x.Id);
},
comment: "商户入驻审核日志。");
migrationBuilder.CreateTable(
name: "merchant_categories",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false, comment: "实体唯一标识。")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false, comment: "类目名称。"),
DisplayOrder = table.Column<int>(type: "integer", nullable: false, defaultValue: 0, comment: "显示顺序,越小越靠前。"),
IsActive = table.Column<bool>(type: "boolean", nullable: false, comment: "是否可用。"),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, comment: "创建时间UTC。"),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "最近一次更新时间UTC从未更新时为 null。"),
DeletedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "软删除时间UTC未删除时为 null。"),
CreatedBy = table.Column<long>(type: "bigint", nullable: true, comment: "创建人用户标识,匿名或系统操作时为 null。"),
UpdatedBy = table.Column<long>(type: "bigint", nullable: true, comment: "最后更新人用户标识,匿名或系统操作时为 null。"),
DeletedBy = table.Column<long>(type: "bigint", nullable: true, comment: "删除人用户标识(软删除),未删除时为 null。"),
TenantId = table.Column<long>(type: "bigint", nullable: false, comment: "所属租户 ID。")
},
constraints: table =>
{
table.PrimaryKey("PK_merchant_categories", x => x.Id);
},
comment: "商户可选类目。");
migrationBuilder.CreateTable(
name: "store_pickup_settings",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false, comment: "实体唯一标识。")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
StoreId = table.Column<long>(type: "bigint", nullable: false, comment: "门店标识。"),
AllowToday = table.Column<bool>(type: "boolean", nullable: false, comment: "是否允许当天自提。"),
AllowDaysAhead = table.Column<int>(type: "integer", nullable: false, comment: "可预约天数(含当天)。"),
DefaultCutoffMinutes = table.Column<int>(type: "integer", nullable: false, defaultValue: 30, comment: "默认截单分钟(开始前多少分钟截止)。"),
MaxQuantityPerOrder = table.Column<int>(type: "integer", nullable: true, comment: "单笔自提最大份数。"),
RowVersion = table.Column<byte[]>(type: "bytea", rowVersion: true, nullable: false, comment: "并发控制字段。"),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, comment: "创建时间UTC。"),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "最近一次更新时间UTC从未更新时为 null。"),
DeletedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "软删除时间UTC未删除时为 null。"),
CreatedBy = table.Column<long>(type: "bigint", nullable: true, comment: "创建人用户标识,匿名或系统操作时为 null。"),
UpdatedBy = table.Column<long>(type: "bigint", nullable: true, comment: "最后更新人用户标识,匿名或系统操作时为 null。"),
DeletedBy = table.Column<long>(type: "bigint", nullable: true, comment: "删除人用户标识(软删除),未删除时为 null。"),
TenantId = table.Column<long>(type: "bigint", nullable: false, comment: "所属租户 ID。")
},
constraints: table =>
{
table.PrimaryKey("PK_store_pickup_settings", x => x.Id);
},
comment: "门店自提配置。");
migrationBuilder.CreateTable(
name: "store_pickup_slots",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false, comment: "实体唯一标识。")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
StoreId = table.Column<long>(type: "bigint", nullable: false, comment: "门店标识。"),
Name = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false, comment: "档期名称。"),
StartTime = table.Column<TimeSpan>(type: "interval", nullable: false, comment: "当天开始时间UTC。"),
EndTime = table.Column<TimeSpan>(type: "interval", nullable: false, comment: "当天结束时间UTC。"),
CutoffMinutes = table.Column<int>(type: "integer", nullable: false, defaultValue: 30, comment: "截单分钟(开始前多少分钟截止)。"),
Capacity = table.Column<int>(type: "integer", nullable: false, comment: "容量(份数)。"),
ReservedCount = table.Column<int>(type: "integer", nullable: false, comment: "已占用数量。"),
Weekdays = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: false, comment: "适用星期(逗号分隔 1-7。"),
IsEnabled = table.Column<bool>(type: "boolean", nullable: false, comment: "是否启用。"),
RowVersion = table.Column<byte[]>(type: "bytea", rowVersion: true, nullable: false, comment: "并发控制字段。"),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, comment: "创建时间UTC。"),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "最近一次更新时间UTC从未更新时为 null。"),
DeletedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "软删除时间UTC未删除时为 null。"),
CreatedBy = table.Column<long>(type: "bigint", nullable: true, comment: "创建人用户标识,匿名或系统操作时为 null。"),
UpdatedBy = table.Column<long>(type: "bigint", nullable: true, comment: "最后更新人用户标识,匿名或系统操作时为 null。"),
DeletedBy = table.Column<long>(type: "bigint", nullable: true, comment: "删除人用户标识(软删除),未删除时为 null。"),
TenantId = table.Column<long>(type: "bigint", nullable: false, comment: "所属租户 ID。")
},
constraints: table =>
{
table.PrimaryKey("PK_store_pickup_slots", x => x.Id);
},
comment: "门店自提档期。");
migrationBuilder.CreateTable(
name: "tenant_announcement_reads",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false, comment: "实体唯一标识。")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
AnnouncementId = table.Column<long>(type: "bigint", nullable: false, comment: "公告 ID。"),
UserId = table.Column<long>(type: "bigint", nullable: true, comment: "已读用户 ID后台账号为空表示租户级已读。"),
ReadAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, comment: "已读时间。"),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, comment: "创建时间UTC。"),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "最近一次更新时间UTC从未更新时为 null。"),
DeletedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "软删除时间UTC未删除时为 null。"),
CreatedBy = table.Column<long>(type: "bigint", nullable: true, comment: "创建人用户标识,匿名或系统操作时为 null。"),
UpdatedBy = table.Column<long>(type: "bigint", nullable: true, comment: "最后更新人用户标识,匿名或系统操作时为 null。"),
DeletedBy = table.Column<long>(type: "bigint", nullable: true, comment: "删除人用户标识(软删除),未删除时为 null。"),
TenantId = table.Column<long>(type: "bigint", nullable: false, comment: "所属租户 ID。")
},
constraints: table =>
{
table.PrimaryKey("PK_tenant_announcement_reads", x => x.Id);
},
comment: "租户公告已读记录。");
migrationBuilder.CreateTable(
name: "tenant_announcements",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false, comment: "实体唯一标识。")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Title = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false, comment: "公告标题。"),
Content = table.Column<string>(type: "text", nullable: false, comment: "公告正文(可为 Markdown/HTML前端自行渲染。"),
AnnouncementType = table.Column<int>(type: "integer", nullable: false, comment: "公告类型。"),
Priority = table.Column<int>(type: "integer", nullable: false, comment: "展示优先级,数值越大越靠前。"),
EffectiveFrom = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, comment: "生效时间UTC。"),
EffectiveTo = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "失效时间UTC为空表示长期有效。"),
IsActive = table.Column<bool>(type: "boolean", nullable: false, comment: "是否启用。"),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, comment: "创建时间UTC。"),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "最近一次更新时间UTC从未更新时为 null。"),
DeletedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "软删除时间UTC未删除时为 null。"),
CreatedBy = table.Column<long>(type: "bigint", nullable: true, comment: "创建人用户标识,匿名或系统操作时为 null。"),
UpdatedBy = table.Column<long>(type: "bigint", nullable: true, comment: "最后更新人用户标识,匿名或系统操作时为 null。"),
DeletedBy = table.Column<long>(type: "bigint", nullable: true, comment: "删除人用户标识(软删除),未删除时为 null。"),
TenantId = table.Column<long>(type: "bigint", nullable: false, comment: "所属租户 ID。")
},
constraints: table =>
{
table.PrimaryKey("PK_tenant_announcements", x => x.Id);
},
comment: "租户公告。");
migrationBuilder.CreateTable(
name: "tenant_audit_logs",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false, comment: "实体唯一标识。")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
TenantId = table.Column<long>(type: "bigint", nullable: false, comment: "关联的租户标识。"),
Action = table.Column<int>(type: "integer", nullable: false, comment: "操作类型。"),
Title = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false, comment: "日志标题。"),
Description = table.Column<string>(type: "character varying(1024)", maxLength: 1024, nullable: true, comment: "详细描述。"),
OperatorId = table.Column<long>(type: "bigint", nullable: true, comment: "操作人 ID。"),
OperatorName = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true, comment: "操作人名称。"),
PreviousStatus = table.Column<int>(type: "integer", nullable: true, comment: "原状态。"),
CurrentStatus = table.Column<int>(type: "integer", nullable: true, comment: "新状态。"),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, comment: "创建时间UTC。"),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "最近一次更新时间UTC从未更新时为 null。"),
DeletedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "软删除时间UTC未删除时为 null。"),
CreatedBy = table.Column<long>(type: "bigint", nullable: true, comment: "创建人用户标识,匿名或系统操作时为 null。"),
UpdatedBy = table.Column<long>(type: "bigint", nullable: true, comment: "最后更新人用户标识,匿名或系统操作时为 null。"),
DeletedBy = table.Column<long>(type: "bigint", nullable: true, comment: "删除人用户标识(软删除),未删除时为 null。")
},
constraints: table =>
{
table.PrimaryKey("PK_tenant_audit_logs", x => x.Id);
},
comment: "租户运营审核日志。");
migrationBuilder.CreateTable(
name: "tenant_subscription_histories",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false, comment: "实体唯一标识。")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
TenantId = table.Column<long>(type: "bigint", nullable: false, comment: "租户标识。"),
TenantSubscriptionId = table.Column<long>(type: "bigint", nullable: false, comment: "对应的订阅 ID。"),
FromPackageId = table.Column<long>(type: "bigint", nullable: false, comment: "原套餐 ID。"),
ToPackageId = table.Column<long>(type: "bigint", nullable: false, comment: "新套餐 ID。"),
ChangeType = table.Column<int>(type: "integer", nullable: false, comment: "变更类型。"),
EffectiveFrom = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, comment: "生效时间。"),
EffectiveTo = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, comment: "到期时间。"),
Amount = table.Column<decimal>(type: "numeric", nullable: true, comment: "相关费用。"),
Currency = table.Column<string>(type: "character varying(8)", maxLength: 8, nullable: true, comment: "币种。"),
Notes = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: true, comment: "备注。"),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, comment: "创建时间UTC。"),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "最近一次更新时间UTC从未更新时为 null。"),
DeletedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "软删除时间UTC未删除时为 null。"),
CreatedBy = table.Column<long>(type: "bigint", nullable: true, comment: "创建人用户标识,匿名或系统操作时为 null。"),
UpdatedBy = table.Column<long>(type: "bigint", nullable: true, comment: "最后更新人用户标识,匿名或系统操作时为 null。"),
DeletedBy = table.Column<long>(type: "bigint", nullable: true, comment: "删除人用户标识(软删除),未删除时为 null。")
},
constraints: table =>
{
table.PrimaryKey("PK_tenant_subscription_histories", x => x.Id);
},
comment: "租户套餐订阅变更记录。");
migrationBuilder.CreateTable(
name: "tenant_verification_profiles",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false, comment: "实体唯一标识。")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
TenantId = table.Column<long>(type: "bigint", nullable: false, comment: "对应的租户标识。"),
Status = table.Column<int>(type: "integer", nullable: false, comment: "实名状态。"),
BusinessLicenseNumber = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true, comment: "营业执照编号。"),
BusinessLicenseUrl = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: true, comment: "营业执照文件地址。"),
LegalPersonName = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true, comment: "法人姓名。"),
LegalPersonIdNumber = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: true, comment: "法人身份证号。"),
LegalPersonIdFrontUrl = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: true, comment: "法人身份证正面。"),
LegalPersonIdBackUrl = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: true, comment: "法人身份证反面。"),
BankAccountName = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true, comment: "开户名。"),
BankAccountNumber = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true, comment: "银行账号。"),
BankName = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true, comment: "银行名称。"),
AdditionalDataJson = table.Column<string>(type: "text", nullable: true, comment: "附加资料JSON。"),
SubmittedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "提交时间。"),
ReviewedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "审核时间。"),
ReviewedBy = table.Column<long>(type: "bigint", nullable: true, comment: "审核人 ID。"),
ReviewedByName = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true, comment: "审核人姓名。"),
ReviewRemarks = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: true, comment: "审核备注。"),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, comment: "创建时间UTC。"),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "最近一次更新时间UTC从未更新时为 null。"),
DeletedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "软删除时间UTC未删除时为 null。"),
CreatedBy = table.Column<long>(type: "bigint", nullable: true, comment: "创建人用户标识,匿名或系统操作时为 null。"),
UpdatedBy = table.Column<long>(type: "bigint", nullable: true, comment: "最后更新人用户标识,匿名或系统操作时为 null。"),
DeletedBy = table.Column<long>(type: "bigint", nullable: true, comment: "删除人用户标识(软删除),未删除时为 null。")
},
constraints: table =>
{
table.PrimaryKey("PK_tenant_verification_profiles", x => x.Id);
},
comment: "租户实名认证资料。");
migrationBuilder.CreateIndex(
name: "IX_inventory_lock_records_TenantId_IdempotencyKey",
table: "inventory_lock_records",
columns: new[] { "TenantId", "IdempotencyKey" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_inventory_lock_records_TenantId_StoreId_ProductSkuId_Status",
table: "inventory_lock_records",
columns: new[] { "TenantId", "StoreId", "ProductSkuId", "Status" });
migrationBuilder.CreateIndex(
name: "IX_merchant_audit_logs_TenantId_MerchantId",
table: "merchant_audit_logs",
columns: new[] { "TenantId", "MerchantId" });
migrationBuilder.CreateIndex(
name: "IX_merchant_categories_TenantId_Name",
table: "merchant_categories",
columns: new[] { "TenantId", "Name" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_store_pickup_settings_TenantId_StoreId",
table: "store_pickup_settings",
columns: new[] { "TenantId", "StoreId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_store_pickup_slots_TenantId_StoreId_Name",
table: "store_pickup_slots",
columns: new[] { "TenantId", "StoreId", "Name" });
migrationBuilder.CreateIndex(
name: "IX_tenant_announcement_reads_TenantId_AnnouncementId_UserId",
table: "tenant_announcement_reads",
columns: new[] { "TenantId", "AnnouncementId", "UserId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_tenant_announcements_TenantId_AnnouncementType_IsActive",
table: "tenant_announcements",
columns: new[] { "TenantId", "AnnouncementType", "IsActive" });
migrationBuilder.CreateIndex(
name: "IX_tenant_announcements_TenantId_EffectiveFrom_EffectiveTo",
table: "tenant_announcements",
columns: new[] { "TenantId", "EffectiveFrom", "EffectiveTo" });
migrationBuilder.CreateIndex(
name: "IX_tenant_audit_logs_TenantId",
table: "tenant_audit_logs",
column: "TenantId");
migrationBuilder.CreateIndex(
name: "IX_tenant_subscription_histories_TenantId_TenantSubscriptionId",
table: "tenant_subscription_histories",
columns: new[] { "TenantId", "TenantSubscriptionId" });
migrationBuilder.CreateIndex(
name: "IX_tenant_verification_profiles_TenantId",
table: "tenant_verification_profiles",
column: "TenantId",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "inventory_lock_records");
migrationBuilder.DropTable(
name: "merchant_audit_logs");
migrationBuilder.DropTable(
name: "merchant_categories");
migrationBuilder.DropTable(
name: "store_pickup_settings");
migrationBuilder.DropTable(
name: "store_pickup_slots");
migrationBuilder.DropTable(
name: "tenant_announcement_reads");
migrationBuilder.DropTable(
name: "tenant_announcements");
migrationBuilder.DropTable(
name: "tenant_audit_logs");
migrationBuilder.DropTable(
name: "tenant_subscription_histories");
migrationBuilder.DropTable(
name: "tenant_verification_profiles");
migrationBuilder.DropColumn(
name: "BatchConsumeStrategy",
table: "inventory_items");
migrationBuilder.DropColumn(
name: "IsPresale",
table: "inventory_items");
migrationBuilder.DropColumn(
name: "IsSoldOut",
table: "inventory_items");
migrationBuilder.DropColumn(
name: "MaxQuantityPerOrder",
table: "inventory_items");
migrationBuilder.DropColumn(
name: "PresaleCapacity",
table: "inventory_items");
migrationBuilder.DropColumn(
name: "PresaleEndTime",
table: "inventory_items");
migrationBuilder.DropColumn(
name: "PresaleLocked",
table: "inventory_items");
migrationBuilder.DropColumn(
name: "PresaleStartTime",
table: "inventory_items");
migrationBuilder.DropColumn(
name: "RowVersion",
table: "inventory_items");
migrationBuilder.DropColumn(
name: "RowVersion",
table: "inventory_batches");
migrationBuilder.AlterColumn<long>(
name: "StoreId",
table: "queue_tickets",
type: "bigint",
nullable: false,
oldClrType: typeof(long),
oldType: "bigint",
oldComment: "获取或设置所属门店 ID。");
migrationBuilder.AlterColumn<long>(
name: "OrderId",
table: "delivery_orders",
type: "bigint",
nullable: false,
oldClrType: typeof(long),
oldType: "bigint",
oldComment: "获取或设置关联订单 ID。");
}
}
}