using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace TakeoutSaaS.Infrastructure.Migrations
{
///
public partial class InitSnowflake_App : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "affiliate_orders",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false, comment: "实体唯一标识。")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
AffiliatePartnerId = table.Column(type: "bigint", nullable: false, comment: "推广人标识。"),
OrderId = table.Column(type: "bigint", nullable: false, comment: "关联订单。"),
BuyerUserId = table.Column(type: "bigint", nullable: false, comment: "用户 ID。"),
OrderAmount = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false, comment: "订单金额。"),
EstimatedCommission = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false, comment: "预计佣金。"),
Status = table.Column(type: "integer", nullable: false, comment: "当前状态。"),
SettledAt = table.Column(type: "timestamp with time zone", nullable: 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_affiliate_orders", x => x.Id);
},
comment: "分销订单记录。");
migrationBuilder.CreateTable(
name: "affiliate_partners",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false, comment: "实体唯一标识。")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
UserId = table.Column(type: "bigint", nullable: true, comment: "用户 ID(如绑定平台账号)。"),
DisplayName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false, comment: "昵称或渠道名称。"),
Phone = table.Column(type: "character varying(32)", maxLength: 32, nullable: true, comment: "联系电话。"),
ChannelType = table.Column(type: "integer", nullable: false, comment: "渠道类型。"),
CommissionRate = table.Column(type: "numeric", nullable: false, comment: "分成比例(0-1)。"),
Status = table.Column(type: "integer", nullable: false, comment: "当前状态。"),
Remarks = table.Column(type: "character varying(256)", maxLength: 256, nullable: 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_affiliate_partners", x => x.Id);
},
comment: "分销/推广合作伙伴。");
migrationBuilder.CreateTable(
name: "affiliate_payouts",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false, comment: "实体唯一标识。")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
AffiliatePartnerId = table.Column(type: "bigint", nullable: false, comment: "合作伙伴标识。"),
Period = table.Column(type: "character varying(32)", maxLength: 32, nullable: false, comment: "结算周期描述。"),
Amount = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false, comment: "结算金额。"),
Status = table.Column(type: "integer", nullable: false, comment: "状态。"),
PaidAt = table.Column(type: "timestamp with time zone", nullable: true, comment: "打款时间。"),
Remarks = table.Column(type: "character varying(256)", maxLength: 256, nullable: 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_affiliate_payouts", x => x.Id);
},
comment: "佣金结算记录。");
migrationBuilder.CreateTable(
name: "cart_item_addons",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false, comment: "实体唯一标识。")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
CartItemId = table.Column(type: "bigint", nullable: false, comment: "所属购物车条目。"),
Name = table.Column(type: "character varying(64)", maxLength: 64, nullable: false, comment: "选项名称。"),
ExtraPrice = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false, comment: "附加价格。"),
OptionId = table.Column(type: "bigint", nullable: true, comment: "选项 ID(可对应 ProductAddonOption)。"),
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_cart_item_addons", x => x.Id);
},
comment: "购物车条目的加料/附加项。");
migrationBuilder.CreateTable(
name: "cart_items",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false, comment: "实体唯一标识。")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ShoppingCartId = table.Column(type: "bigint", nullable: false, comment: "所属购物车标识。"),
ProductId = table.Column(type: "bigint", nullable: false, comment: "商品或 SKU 标识。"),
ProductSkuId = table.Column(type: "bigint", nullable: true, comment: "SKU 标识。"),
ProductName = table.Column(type: "character varying(128)", maxLength: 128, nullable: false, comment: "商品名称快照。"),
UnitPrice = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false, comment: "单价快照。"),
Quantity = table.Column(type: "integer", nullable: false, comment: "数量。"),
Remark = table.Column(type: "character varying(256)", maxLength: 256, nullable: true, comment: "自定义备注(口味要求)。"),
Status = table.Column(type: "integer", nullable: false, comment: "状态。"),
AttributesJson = table.Column(type: "text", nullable: true, comment: "扩展 JSON(规格、加料选项等)。"),
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_cart_items", x => x.Id);
},
comment: "购物车条目。");
migrationBuilder.CreateTable(
name: "chat_messages",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false, comment: "实体唯一标识。")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ChatSessionId = table.Column(type: "bigint", nullable: false, comment: "会话标识。"),
SenderType = table.Column(type: "integer", nullable: false, comment: "发送方类型。"),
SenderUserId = table.Column(type: "bigint", nullable: true, comment: "发送方用户 ID。"),
Content = table.Column(type: "character varying(1024)", maxLength: 1024, nullable: false, comment: "消息内容。"),
ContentType = table.Column(type: "character varying(64)", maxLength: 64, nullable: false, comment: "消息类型(文字/图片/语音等)。"),
IsRead = table.Column(type: "boolean", nullable: false, comment: "是否已读。"),
ReadAt = table.Column(type: "timestamp with time zone", nullable: 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_chat_messages", x => x.Id);
},
comment: "会话消息。");
migrationBuilder.CreateTable(
name: "chat_sessions",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false, comment: "实体唯一标识。")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
SessionCode = table.Column(type: "character varying(64)", maxLength: 64, nullable: false, comment: "会话编号。"),
CustomerUserId = table.Column(type: "bigint", nullable: false, comment: "顾客用户 ID。"),
AgentUserId = table.Column(type: "bigint", nullable: true, comment: "当前客服员工 ID。"),
StoreId = table.Column(type: "bigint", nullable: true, comment: "所属门店(可空为平台)。"),
Status = table.Column(type: "integer", nullable: false, comment: "会话状态。"),
IsBotActive = table.Column(type: "boolean", nullable: false, comment: "是否机器人接待中。"),
StartedAt = table.Column(type: "timestamp with time zone", nullable: false, comment: "开始时间。"),
EndedAt = table.Column(type: "timestamp with time zone", nullable: 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_chat_sessions", x => x.Id);
},
comment: "客服会话。");
migrationBuilder.CreateTable(
name: "checkin_campaigns",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false, comment: "实体唯一标识。")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column(type: "character varying(128)", maxLength: 128, nullable: false, comment: "活动名称。"),
Description = table.Column(type: "character varying(512)", maxLength: 512, nullable: true, comment: "活动描述。"),
StartDate = table.Column(type: "timestamp with time zone", nullable: false, comment: "开始日期。"),
EndDate = table.Column(type: "timestamp with time zone", nullable: false, comment: "结束日期。"),
AllowMakeupCount = table.Column(type: "integer", nullable: false, comment: "支持补签次数。"),
RewardsJson = table.Column(type: "text", nullable: false, comment: "连签奖励 JSON。"),
Status = table.Column(type: "integer", nullable: false, 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_checkin_campaigns", x => x.Id);
},
comment: "签到活动配置。");
migrationBuilder.CreateTable(
name: "checkin_records",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false, comment: "实体唯一标识。")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
CheckInCampaignId = table.Column(type: "bigint", nullable: false, comment: "活动标识。"),
UserId = table.Column(type: "bigint", nullable: false, comment: "用户标识。"),
CheckInDate = table.Column(type: "timestamp with time zone", nullable: false, comment: "签到日期(本地)。"),
IsMakeup = table.Column(type: "boolean", nullable: false, comment: "是否补签。"),
RewardJson = table.Column(type: "text", nullable: false, comment: "获得奖励 JSON。"),
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_checkin_records", x => x.Id);
},
comment: "用户签到记录。");
migrationBuilder.CreateTable(
name: "checkout_sessions",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false, comment: "实体唯一标识。")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
UserId = table.Column(type: "bigint", nullable: false, comment: "用户标识。"),
StoreId = table.Column(type: "bigint", nullable: false, comment: "门店标识。"),
SessionToken = table.Column(type: "character varying(64)", maxLength: 64, nullable: false, comment: "会话 Token。"),
Status = table.Column(type: "integer", nullable: false, comment: "会话状态。"),
ValidationResultJson = table.Column(type: "text", nullable: false, comment: "校验结果明细 JSON。"),
ExpiresAt = table.Column(type: "timestamp with time zone", nullable: false, comment: "过期时间(UTC)。"),
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_checkout_sessions", x => x.Id);
},
comment: "结账会话,记录校验上下文。");
migrationBuilder.CreateTable(
name: "community_comments",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false, comment: "实体唯一标识。")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
PostId = table.Column(type: "bigint", nullable: false, comment: "动态标识。"),
AuthorUserId = table.Column(type: "bigint", nullable: false, comment: "评论人。"),
Content = table.Column(type: "character varying(512)", maxLength: 512, nullable: false, comment: "评论内容。"),
ParentId = table.Column(type: "bigint", nullable: true, comment: "父级评论 ID。"),
IsDeleted = table.Column(type: "boolean", nullable: false, 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_community_comments", x => x.Id);
},
comment: "社区评论。");
migrationBuilder.CreateTable(
name: "community_posts",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false, comment: "实体唯一标识。")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
AuthorUserId = table.Column(type: "bigint", nullable: false, comment: "作者用户 ID。"),
Title = table.Column(type: "character varying(128)", maxLength: 128, nullable: true, comment: "标题。"),
Content = table.Column(type: "text", nullable: false, comment: "内容。"),
MediaJson = table.Column(type: "text", nullable: true, comment: "媒体资源 JSON。"),
Status = table.Column(type: "integer", nullable: false, comment: "状态。"),
LikeCount = table.Column(type: "integer", nullable: false, comment: "点赞数。"),
CommentCount = table.Column(type: "integer", nullable: false, 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_community_posts", x => x.Id);
},
comment: "社区动态。");
migrationBuilder.CreateTable(
name: "community_reactions",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false, comment: "实体唯一标识。")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
PostId = table.Column(type: "bigint", nullable: false, comment: "动态 ID。"),
UserId = table.Column(type: "bigint", nullable: false, comment: "用户 ID。"),
ReactionType = table.Column(type: "integer", nullable: false, comment: "反应类型。"),
ReactedAt = table.Column(type: "timestamp with time zone", nullable: false, 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_community_reactions", x => x.Id);
},
comment: "社区互动反馈。");
migrationBuilder.CreateTable(
name: "coupon_templates",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false, comment: "实体唯一标识。")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column(type: "character varying(128)", maxLength: 128, nullable: false, comment: "模板名称。"),
CouponType = table.Column(type: "integer", nullable: false, comment: "券类型。"),
Value = table.Column(type: "numeric", nullable: false, comment: "面值或折扣额度。"),
DiscountCap = table.Column(type: "numeric", nullable: true, comment: "折扣上限(针对折扣券)。"),
MinimumSpend = table.Column(type: "numeric", nullable: true, comment: "最低消费门槛。"),
ValidFrom = table.Column(type: "timestamp with time zone", nullable: true, comment: "可用开始时间。"),
ValidTo = table.Column(type: "timestamp with time zone", nullable: true, comment: "可用结束时间。"),
RelativeValidDays = table.Column(type: "integer", nullable: true, comment: "有效天数(相对发放时间)。"),
TotalQuantity = table.Column(type: "integer", nullable: true, comment: "总发放数量上限。"),
ClaimedQuantity = table.Column(type: "integer", nullable: false, comment: "已领取数量。"),
StoreScopeJson = table.Column(type: "text", nullable: true, comment: "适用门店 ID 集合(JSON)。"),
ProductScopeJson = table.Column(type: "text", nullable: true, comment: "适用品类或商品范围(JSON)。"),
ChannelsJson = table.Column(type: "text", nullable: true, comment: "发放渠道(JSON)。"),
AllowStack = table.Column(type: "boolean", nullable: false, comment: "是否允许叠加其他优惠。"),
Status = table.Column(type: "integer", nullable: false, comment: "状态。"),
Description = table.Column(type: "character varying(512)", maxLength: 512, nullable: 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_coupon_templates", x => x.Id);
},
comment: "优惠券模板。");
migrationBuilder.CreateTable(
name: "coupons",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false, comment: "实体唯一标识。")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
CouponTemplateId = table.Column(type: "bigint", nullable: false, comment: "模板标识。"),
Code = table.Column(type: "character varying(32)", maxLength: 32, nullable: false, comment: "券码或序列号。"),
UserId = table.Column(type: "bigint", nullable: false, comment: "归属用户。"),
OrderId = table.Column(type: "bigint", nullable: true, comment: "订单 ID(已使用时记录)。"),
Status = table.Column(type: "integer", nullable: false, comment: "状态。"),
IssuedAt = table.Column(type: "timestamp with time zone", nullable: false, comment: "发放时间。"),
UsedAt = table.Column(type: "timestamp with time zone", nullable: true, comment: "使用时间。"),
ExpireAt = table.Column(type: "timestamp with time zone", nullable: false, 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_coupons", x => x.Id);
},
comment: "用户领取的券。");
migrationBuilder.CreateTable(
name: "delivery_events",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false, comment: "实体唯一标识。")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
DeliveryOrderId = table.Column(type: "bigint", nullable: false, comment: "配送单标识。"),
EventType = table.Column(type: "integer", nullable: false, comment: "事件类型。"),
Message = table.Column(type: "character varying(256)", maxLength: 256, nullable: false, comment: "事件描述。"),
Payload = table.Column(type: "text", nullable: true, comment: "原始数据 JSON。"),
OccurredAt = table.Column(type: "timestamp with time zone", nullable: false, 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_delivery_events", x => x.Id);
},
comment: "配送状态事件流水。");
migrationBuilder.CreateTable(
name: "delivery_orders",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false, comment: "实体唯一标识。")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
OrderId = table.Column(type: "bigint", nullable: false),
Provider = table.Column(type: "integer", nullable: false, comment: "配送服务商。"),
ProviderOrderId = table.Column(type: "character varying(64)", maxLength: 64, nullable: true, comment: "第三方配送单号。"),
Status = table.Column(type: "integer", nullable: false, comment: "状态。"),
DeliveryFee = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: true, comment: "配送费。"),
CourierName = table.Column(type: "character varying(64)", maxLength: 64, nullable: true, comment: "骑手姓名。"),
CourierPhone = table.Column(type: "character varying(32)", maxLength: 32, nullable: true, comment: "骑手电话。"),
DispatchedAt = table.Column(type: "timestamp with time zone", nullable: true, comment: "下发时间。"),
PickedUpAt = table.Column(type: "timestamp with time zone", nullable: true, comment: "取餐时间。"),
DeliveredAt = table.Column(type: "timestamp with time zone", nullable: true, comment: "完成时间。"),
FailureReason = table.Column(type: "character varying(256)", maxLength: 256, nullable: 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