diff --git a/Document/10_TODO.md b/Document/10_TODO.md index 31f7d26..48327f0 100644 --- a/Document/10_TODO.md +++ b/Document/10_TODO.md @@ -1,62 +1,57 @@ -# TODO Roadmap +# TODO Roadmap -说明:本清单覆盖当前阶段的骨架搭建与核心基础能力(不含部署与CI/CD,留到项目跑通后再做)。 +> 当前列表为原 11 号文档中的待办事项,已迁移到此处并统一以复选框形式标记。若无特殊说明,均尚未完成。 -## A. 基础骨架与规范 -- [x] 统一返回结果/异常处理中间件(Shared.Web) -- [x] 模型验证、验证失败统一输出(Shared.Web) -- [x] 统一日志(Serilog)与请求日志/TraceId(Shared.Web) -- [x] API 版本化与分组(AdminApi、MiniApi、UserApi) -- [x] Swagger 定制(鉴权按钮、分组说明、示例) -- [x] 安全中间件:Security Headers、CORS 策略(按端区分) +## 1. 配置与基础设施(高优) +- [x] Development/Production 数据库连接与 Secret 落地(Staging 暂不需要)。 +- [x] Redis 服务部署完毕并记录配置。 +- [x] RabbitMQ 服务部署完毕并记录配置。 +- [x] COS 密钥配置补录完毕。 +- [ ] OSS 密钥配置补录完毕(待采购)。 +- [ ] SMS 平台密钥配置补录完毕(待采购)。 +- [x] WeChat Mini 程序密钥配置补录完毕(AppID:wx30f91e6afe79f405,AppSecret:64324a7f604245301066ba7c3add488e,已同步到 admin/mini 配置并登记更新人)。 +- [x] PostgreSQL 基础实例部署完毕并记录配置。 +- [x] Postgres/Redis 接入文档 + IaC/脚本补齐(见 Document/infra/postgres_redis.md 与 deploy/postgres|redis)。 +- [x] RabbitMQ/Redis/Hangfire storage scripts available (see deploy/postgres and deploy/redis). +- [ ] admin/mini/user/gateway 网关域名、证书、CORS 列表整理完成。 +- [ ] Hangfire Dashboard 启用并新增 Admin 角色验证/网关白名单。 -## B. 认证与权限 -- [x] JWT 颁发与刷新(AdminApi、MiniApi) -- [x] RBAC 权限模型(角色/权限/策略)与特性授权(AdminApi) -- [x] 小程序登录(微信 code2Session)并绑定用户账户(MiniApi) -- [x] 登录防刷限流(MiniApi) +## 2. 数据与迁移(高优) +- [ ] App/Identity/Dictionary/Hangfire 四个 DbContext 均生成初始 Migration 并成功 update database。 +- [ ] 商户/门店/商品/订单/支付/配送等实体与仓储实现完成,提供 CRUD + 查询。 +- [ ] 系统参数、默认租户、管理员账号、基础字典的种子脚本可重复执行。 -## C. 多租户与参数字典 -- [x] 多租户中间件:从 Header/域名解析租户(Shared.Web + Tenancy) -- [x] EF Core 全局查询过滤(tenant_id) -- [x] 参数字典模块(系统参数/业务参数)CRUD 与缓存(Dictionary 模块) +## 3. 稳定性与质量 +- [ ] Dictionary/Identity/Storage/Sms/Messaging/Scheduler 的 xUnit+FluentAssertions 单元测试框架搭建。 +- [ ] WebApplicationFactory + Testcontainers 拉起 Postgres/Redis/RabbitMQ/MinIO 的集成测试模板。 +- [ ] .editorconfig、.globalconfig、Roslyn 分析器配置仓库通用规则并启用 CI 检查。 -## D. 数据访问与多数据源 -- [x] EF Core 10 基础上下文、实体基类、审计字段 -- [x] 读写分离/多数据源配置(主写、从读) -- [x] Dapper 基础设施封装(统计/报表类查询) +## 4. 安全与合规 +- [ ] RBAC 权限、租户隔离、用户/权限洞察 API 完整演示并在 Swagger 中提供示例。 +- [ ] 登录/刷新流程增加 IP 校验、租户隔离、验证码/频率限制。 +- [ ] 登录/权限/敏感操作日志可追溯,提供查询接口或 Kibana Saved Search。 +- [ ] Secret Store/KeyVault/KMS 管理敏感配置,禁止密钥写入 Git/数据库明文。 -## E. 文件与存储 -- [x] 存储模块抽象(腾讯云COS/七牛云/阿里云OSS) -- [x] 上传接口(AdminApi、MiniApi)与签名直传预留 -- [x] 图片/文件访问安全策略(防盗链、过期签名) +## 5. 观测与运维 +- [ ] TraceId 贯通,并在 Serilog 中输出 Console/File/ELK 三种目标。 +- [ ] Prometheus exporter 暴露关键指标,/health 探针与告警规则同步推送。 +- [ ] PostgreSQL 全量/增量备份脚本及一次真实恢复演练报告。 -## F. 短信与消息队列 -- [x] 短信模块(阿里云/腾讯云 适配占位)与验证码发送 -- [x] MQ 模块(RabbitMQ)Publisher/Subscriber 抽象 -- [x] 业务事件定义(订单创建/支付成功等)与事件发布入口 +## 6. 业务能力补全 +- [ ] 商户/门店/菜品 API 完成并在 MQ 中投递上架/支付成功事件。 +- [ ] 配送对接 API 支持下单/取消/查询并完成签名验签中间件。 +- [ ] 小程序端商品浏览、下单、支付、评价、图片直传等 API 可闭环跑通。 -## G. 调度与定时任务 -- [x] 调度模块(Quartz/Hangfire 二选一,默认 Hangfire) -- [x] 基础任务:订单超时取消、优惠券过期处理、日志清理 -- [x] 调度面板(后续 AdminUI 对接) +## 7. 前后台 UI 对接 +- [ ] Admin UI 通过 OpenAPI 生成或手写界面,接入 Hangfire Dashboard/MQ 监控只读模式。 +- [ ] 小程序端完成登录、菜单浏览、下单、支付、物流轨迹、素材直传闭环。 -## H. 第三方配送对接(仅第三方) -- [ ] 配送适配抽象(达达/闪送/顺丰同城等) -- [ ] 统一下单/取消/查询接口与回调验签 -- [ ] AdminApi 后台运力单查询与补单 +## 8. CI/CD 与发布 +- [ ] CI/CD 流水线覆盖构建、发布、静态扫描、数据库迁移。 +- [ ] Dev/Staging/Prod 多环境配置矩阵 + 基础设施 IaC 脚本。 +- [ ] 版本与发布说明模板整理并在仓库中提供示例。 -## I. 网关与横切能力 -- [x] YARP 路由拆分(/api/admin、/api/mini、/api/user) -- [x] 网关级限流与请求日志 -- [x] 透传鉴权/租户标识与统一错误页 - -## J. 测试与质量 -- [ ] 单元测试工程骨架(xUnit + FluentAssertions) -- [ ] 集成测试基座(WebApplicationFactory、测试容器) -- [ ] 静态分析与风格规范(.editorconfig) - -## K. 文档与规范落地 -- [ ] 在文档中补充:仅第三方配送的接口与回调规范 -- [ ] MiniApi 认证流程图(微信登录)与错误码 -- [ ] 模块间调用关系图与依赖边界 +## 9. 文档与知识库 +- [ ] 接口文档、领域模型、关键约束使用 Markdown 或 API Portal 完整记录。 +- [ ] 运行手册包含部署步骤、资源拓扑、故障排查手册。 +- [ ] 安全合规模板覆盖数据分级、密钥管理、审计流程并形成可复用表格。 diff --git a/Document/11_WaitTODO.md b/Document/11_WaitTODO.md index d812c4d..700f366 100644 --- a/Document/11_WaitTODO.md +++ b/Document/11_WaitTODO.md @@ -1,49 +1,53 @@ -# 下一步 TODO(骨架完成后) +# 里程碑待办追踪 -说明:当前骨架已覆盖认证、权限、多租户、存储、短信、MQ、调度、网关等基础能力。下面的清单用于进入“可运行/可上线”的补全与质量阶段,可按优先级推进。 +> 按“小程序版模块规划”划分四个里程碑;每个里程碑只含对应范围的任务,便于分阶段推进。 -## 1. 配置与基础设施落地(高优) -- 补充真实配置:数据库/Redis/RabbitMQ/对象存储/SMS/WeChat Mini/身份密钥,并分环境管理(Development/Staging/Production)。 -- 准备基础设施:PostgreSQL 主从、Redis(哨兵/集群)、RabbitMQ、COS/OSS、Hangfire 存储库;完善 docker-compose 与部署说明。 -- 网关与服务域名规划:为 admin/mini/user/gateway 配置实际域名、TLS 证书与 CORS 列表。 -- Hangfire Dashboard 鉴权:开启并加上 Admin 角色校验或网关白名单。 +--- +## Phase 1(当前阶段):租户/商家入驻、门店与菜品、扫码堂食、基础下单支付、预购自提、第三方配送骨架 +- [ ] 管理端租户 API:注册、实名认证、套餐订阅/续费/升降配、审核流,Swagger ≥6 个端点,含审核日志。 +- [ ] 商家入驻 API:证照上传、合同管理、类目选择,驱动待审/审核/驳回/通过状态机,文件持久在 COS。 +- [ ] RBAC 模板:平台管理员、租户管理员、店长、店员四角色模板;API 可复制并允许租户自定义扩展。 +- [ ] 配额与套餐:TenantPackage CRUD、订阅/续费/配额校验(门店/账号/短信/配送单量),超额返回 409 并记录 TenantQuotaUsage。 +- [ ] 租户运营面板:欠费/到期告警、账单列表、公告通知接口,支持已读状态并在 Admin UI 展示。 +- [ ] 门店管理:Store/StoreBusinessHour/StoreDeliveryZone/StoreHoliday CRUD 完整,含 GeoJSON 配送范围及能力开关。 +- [ ] 桌码管理:批量生成桌码、绑定区域/容量、导出二维码 ZIP(POST /api/admin/stores/{id}/tables 可下载)。 +- [ ] 员工排班:创建员工、绑定门店角色、维护 StoreEmployeeShift,可查询未来 7 日排班。 +- [ ] 桌码扫码入口:Mini 端解析二维码,GET /api/mini/tables/{code}/context 返回门店、桌台、公告。 +- [ ] 菜品建模:分类、SPU、SKU、规格/加料组、价格策略、媒资 CRUD + 上下架流程;Mini 端可拉取完整 JSON。 +- [ ] 库存体系:SKU 库存、批次、调整、售罄管理,支持预售/档期锁定并在订单中扣减/释放。 +- [ ] 自提档期:门店配置自提时间窗、容量、截单时间;Mini 端据此限制下单时间。 +- [ ] 购物车服务:ShoppingCart/CartItem/CartItemAddon API 支持并发锁、限购、券/积分预校验,保证并发无脏数据。 +- [ ] 订单与支付:堂食/自提/配送下单、微信/支付宝支付、优惠券/积分抵扣、订单状态机与通知链路齐全。 +- [ ] 桌台账单:合单/拆单、结账、电子小票、桌台释放,完成结账后恢复 Idle 并生成票据 URL。 +- [ ] 自配送骨架:骑手管理、取送件信息录入、费用补贴记录,Admin 端可派单并更新 DeliveryOrder。 +- [ ] 第三方配送抽象:统一下单/取消/加价/查询接口,支持达达、美团、闪送等,含回调验签与异常补偿骨架。 +- [ ] 预购自提核销:提货码生成、手机号/二维码核销、自提柜/前台流程,超时自动取消或退款,记录操作者与时间。 +- [ ] 指标与日志:Prometheus 输出订单创建、支付成功率、配送回调耗时等,Grafana ≥8 个图表;关键流程日志记录 TraceId + 业务 ID。 +- [ ] 测试:Phase 1 核心 API 具备 ≥30 条自动化用例(单元 + 集成),覆盖租户→商户→下单链路。 -## 2. 数据与迁移(高优) -- 建立 EF Core Migration 基线并生成数据库(App/Identity/Dictionary/Hangfire)。 -- 设计并落地核心业务表(商户/门店/商品/订单/支付/配送等),补齐 Domain 与 Infrastructure 仓储。 -- 数据初始化/种子:系统参数、默认租户、管理员、基础字典。 +--- +## Phase 2(下一阶段):拼单、优惠券与基础营销、会员积分/会员日、客服聊天、同城自配送调度、搜索 +- [ ] 拼单引擎:GroupOrder/Participant CRUD、发起/加入/成团条件、自动解散与退款、团内消息与提醒。 +- [ ] 优惠券与基础营销:模板管理、领券、核销、库存/有效期/叠加规则,基础抽奖/秒杀/满减活动。 +- [ ] 会员与积分:会员档案、等级/成长值、会员日通知;积分获取/消耗、有效期、黑名单。 +- [ ] 客服聊天:实时会话、机器人/人工切换、排队/转接、消息模板、敏感词审查、工单流转与评价。 +- [ ] 同城自配送调度:骑手智能指派、路线估时、无接触配送、费用补贴策略、调度看板。 +- [ ] 搜索:门店/菜品/活动/优惠券搜索,过滤/排序、热门/历史记录、联想与纠错。 -## 3. 质量与测试(高优) -- 单元测试骨架:xUnit + FluentAssertions(Dictionary、Identity、Storage、Sms、Messaging、Scheduler)。 -- 集成测试基座:WebApplicationFactory + Testcontainers(Postgres/Redis/RabbitMQ/MinIO 可选)。 -- 静态分析:添加 .editorconfig/.globalconfig,启用可空警告、风格规则,接入 Roslyn 分析器。 +--- +## Phase 3:分销返利、签到打卡、预约预订、地图导航、社区、高阶营销、风控与补偿 +- [ ] 分销返利:AffiliatePartner/Order/Payout 管理,佣金阶梯、结算周期、税务信息、违规处理。 +- [ ] 签到打卡:CheckInCampaign/Record、连签奖励、补签、积分/券/成长值奖励、反作弊机制。 +- [ ] 预约预订:档期/资源占用、预约下单/支付、提醒/改期/取消、到店核销与履约记录。 +- [ ] 地图导航扩展:附近门店/推荐、距离/路线规划、跳转原生导航、导航请求埋点。 +- [ ] 社区:动态发布、评论、点赞、话题/标签、图片/视频审核、举报与风控,店铺口碑展示。 +- [ ] 高阶营销:秒杀/抽奖/裂变、裂变海报、爆款推荐位、多渠道投放分析。 +- [ ] 风控与审计:黑名单、频率限制、异常行为监控、审计日志、补偿与告警体系。 -## 4. 安全与合规 -- 完善鉴权:网关透传与后端校验的租户/用户/权限;Swagger 鉴权示例。 -- 输入校验与防刷:全局限流策略(按 IP/租户),登录与验证码防刷策略参数化。 -- 日志与审计:敏感字段脱敏,登录/权限/管理操作审计日志模型与落库。 -- 配置机密:使用 Secret Store/环境变量/KMS 管理密钥,禁止明文提交。 - -## 5. 可观测性与运维 -- 日志链路:统一 TraceId 透传(网关→服务),配置 Serilog 输出(Console/File/ELK)与留存策略。 -- 指标/监控:Prometheus exporter、健康检查探针(/health)、告警规则草案。 -- 备份恢复:PostgreSQL 全量/增量备份脚本,恢复演练记录。 - -## 6. 业务功能补全 -- 订单/商品/商户等领域建模与应用服务接口实现,结合 MQ 事件发布(订单创建、支付成功等)。 -- 配送对接抽象实现(达达/闪送/顺丰同城)占位,提供下单/取消/查询接口与回调验签。 -- 小程序端接口补齐:商品浏览、下单、支付、评价、上传图片直传联调。 - -## 7. 前台/后台 UI 对接 -- Admin UI:接入 Swagger 导出的 OpenAPI,生成或手写管理端界面;接入 Hangfire Dashboard/MQ 监控只读访问。 -- MiniApp:小程序登录流程与错误码文档完善,联调上传、下单、支付链路。 - -## 8. CI/CD 与发布 -- 建立流水线:构建/测试/扫描(SAST)、镜像推送、数据库迁移步骤。 -- 多环境部署策略:Dev/Staging/Prod 配置隔离,蓝绿或滚动发布方案草拟。 -- 版本与变更管理:约定版本号/发布说明模板。 - -## 9. 文档补全 -- 更新接口文档(新增业务 API、错误码、回调规范)、模块依赖关系图。 -- 运维手册:启动参数、环境变量列表、端口/域名映射、常见故障排查。 -- 安全与合规清单:数据分类分级、审计、留存周期。 +--- +## Phase 4:性能优化、缓存、运营大盘、测试与文档、上线与监控 +- [ ] 性能与缓存:热点接口缓存、慢查询治理、批处理优化、异步化改造。 +- [ ] 可靠性:幂等与重试策略、任务调度补偿、链路追踪、告警联动。 +- [ ] 运营大盘:交易/营销/履约/用户维度的细分报表、GMV/成本/毛利分析。 +- [ ] 文档与测试:完整测试矩阵、性能测试报告、上线手册、回滚方案。 +- [ ] 监控与运维:上线发布流程、灰度/回滚策略、系统稳定性指标、24x7 监控与告警。 diff --git a/Document/16_设计时DbContext配置指引.md b/Document/16_设计时DbContext配置指引.md new file mode 100644 index 0000000..d1fa968 --- /dev/null +++ b/Document/16_设计时DbContext配置指引.md @@ -0,0 +1,89 @@ +# 设计时 DbContext 配置指引 + +> 目的:在执行 `dotnet ef` 命令时无需硬编码数据库连接,可根据 appsettings 与环境变量自动加载。本文覆盖环境变量设置、配置目录指定等细节。 + +## 一、设计时工厂读取逻辑概述 +设计时工厂(`DesignTimeDbContextFactoryBase`)按下面顺序解析连接串: +1. 若设置了 `TAKEOUTSAAS_APP_CONNECTION` / `TAKEOUTSAAS_IDENTITY_CONNECTION` / `TAKEOUTSAAS_DICTIONARY_CONNECTION` 等环境变量,则优先使用。 +2. 否则查找配置文件: + - 从当前目录开始向上找到含 `TakeoutSaaS.sln` 的仓库根。 + - 依次检查 `src/Api/TakeoutSaaS.AdminApi`、`src/Api/TakeoutSaaS.UserApi`、`src/Api/TakeoutSaaS.MiniApi` 等目录,如果存在 `appsettings.json` 或 `appsettings.{Environment}.json` 则加载。 + - 若未找到,可通过环境变量 `TAKEOUTSAAS_APPSETTINGS_DIR` 指定包含 appsettings 文件的目录。 + +配置结构示例(出现在 AdminApi/MiniApi/UserApi 的 appsettings): +```json +"Database": { + "DataSources": { + "AppDatabase": { + "Write": "Host=120.53...;Database=takeout_app_db;Username=...;Password=...", + "Reads": [ + "Host=120.53...;Database=takeout_app_db;Username=...;Password=..." + ] + }, + "IdentityDatabase": { + "Write": "...", + "Reads": [ "..." ] + }, + "DictionaryDatabase": { + "Write": "...", + "Reads": [ "..." ] + } + } +} +``` +设计时工厂会根据数据源名称(`DatabaseConstants.AppDataSource` 等)读取 `Write` 连接串,实现与运行时一致。 + +## 二、环境变量配置 +### 1. Windows PowerShell +```powershell +# 指向包含 appsettings.json 的目录 +$env:TAKEOUTSAAS_APPSETTINGS_DIR = \"D:\\HAZCode\\TakeOut\\src\\Api\\TakeoutSaaS.AdminApi\" + +#(可选)覆盖 AppDatabase 连接串 +$env:TAKEOUTSAAS_APP_CONNECTION = \"Host=120.53.222.17;Port=5432;Database=takeout_app_db;Username=app_user;Password=***\" + +#(可选)覆盖 IdentityDatabase 连接串 +$env:TAKEOUTSAAS_IDENTITY_CONNECTION = \"Host=...;Database=takeout_identity_db;Username=...;Password=...\" + +#����ѡ������ DictionaryDatabase ���Ӵ� +$env:TAKEOUTSAAS_DICTIONARY_CONNECTION = "Host=...;Database=takeout_dictionary_db;Username=...;Password=..." +``` + +### 2. Linux / macOS +```bash +export TAKEOUTSAAS_APPSETTINGS_DIR=/home/user/TakeOut/src/Api/TakeoutSaaS.AdminApi +export TAKEOUTSAAS_APP_CONNECTION=\"Host=120.53.222.17;Port=5432;Database=takeout_app_db;Username=app_user;Password=***\" +export TAKEOUTSAAS_IDENTITY_CONNECTION=\"Host=...;Database=takeout_identity_db;Username=...;Password=...\" +export TAKEOUTSAAS_DICTIONARY_CONNECTION="Host=...;Database=takeout_dictionary_db;Username=...;Password=..." +``` + +> 注意:若设置了 `TAKEOUTSAAS_APP_CONNECTION`,则无需在 appsettings 中提供 `Write` 连接串,反之亦然。不要将明文密码写入代码仓库,建议使用 Secret Manager 或部署环境的安全存储。 + +## 三、执行脚本示例 +完成上述环境变量配置后即可执行: +```powershell +# TakeoutAppDbContext(业务库) +dotnet tool run dotnet-ef database update ` + --project src/Infrastructure/TakeoutSaaS.Infrastructure/TakeoutSaaS.Infrastructure.csproj ` + --startup-project src/Infrastructure/TakeoutSaaS.Infrastructure/TakeoutSaaS.Infrastructure.csproj ` + --context TakeoutSaaS.Infrastructure.App.Persistence.TakeoutAppDbContext + +# IdentityDbContext(身份库) +dotnet tool run dotnet-ef database update ` + --project src/Infrastructure/TakeoutSaaS.Infrastructure/TakeoutSaaS.Infrastructure.csproj ` + --startup-project src/Infrastructure/TakeoutSaaS.Infrastructure/TakeoutSaaS.Infrastructure.csproj ` + --context TakeoutSaaS.Infrastructure.Identity.Persistence.IdentityDbContext + +# DictionaryDbContext(字典库) +dotnet tool run dotnet-ef database update ` + --project src/Infrastructure/TakeoutSaaS.Infrastructure/TakeoutSaaS.Infrastructure.csproj ` + --startup-project src/Infrastructure/TakeoutSaaS.Infrastructure/TakeoutSaaS.Infrastructure.csproj ` + --context TakeoutSaaS.Infrastructure.Dictionary.Persistence.DictionaryDbContext +``` + +若需迁移 Identity/Dictionary 等上下文,替换 `--context` 参数为对应类型即可。 + +## 四、常见问题 +1. **未找到 appsettings**:确保 `TAKEOUTSAAS_APPSETTINGS_DIR` 指向存在 `appsettings.json` 的目录,或将命令在 API 项目目录中执行。 +2. **密码错误**:确认远程 PostgreSQL 用户/密码是否与 appsettings 或环境变量一致,避免在 CLI 中使用默认的账号。 +3. **多环境配置**:`ASPNETCORE_ENVIRONMENT` 变量可控制加载 `appsettings.{Environment}.json`;默认是 Development。 diff --git a/Document/infra/postgres_redis.md b/Document/infra/postgres_redis.md new file mode 100644 index 0000000..bf6e076 --- /dev/null +++ b/Document/infra/postgres_redis.md @@ -0,0 +1,101 @@ +# PostgreSQL 与 Redis 接入手册 + +> 本文档补齐 `Document/10_TODO.md` 中“Postgres/Redis 接入文档与 IaC/脚本”的要求,统一描述连接信息、账号权限、运维流程,以及可复用的部署脚本位置。 + +## 1. 运行环境总览 + +| 组件 | 地址/端口 | 主要数据库/实例 | 说明 | +| --- | --- | --- | --- | +| PostgreSQL | `120.53.222.17:5432` | `takeout_app_db`、`takeout_identity_db`、`takeout_dictionary_db`、`takeout_hangfire_db` | 线上实例,所有业务上下文共用。 | +| Redis | `49.232.6.45:6379` | 单节点 | 业务缓存/登录限流/刷新令牌存储。 | + +> 注意:所有业务账号都只具备既有库的读写权限,无 `CREATEDB`。若需新库,需使用平台管理员账号(`postgres`)或联系 DBA。 + +## 2. 账号与库映射 + +| 数据库 | 角色 | 密码 | 用途 | +| --- | --- | --- | --- | +| `takeout_app_db` | `app_user` | `AppUser112233` | 业务域 (`TakeoutAppDbContext`) | +| `takeout_identity_db` | `identity_user` | `IdentityUser112233` | 身份域 (`IdentityDbContext`) | +| `takeout_dictionary_db` | `dictionary_user` | `DictionaryUser112233` | 字典域 (`DictionaryDbContext`) | +| `takeout_hangfire_db` | `hangfire_user` | `HangFire112233` | 后台调度/Hangfire | + +Redis 密码:`MsuMshk112233`,见 `appsettings.*.json -> Redis`。 + +## 3. 环境变量/配置注入 + +### PowerShell + +```powershell +$env:TAKEOUTSAAS_APPSETTINGS_DIR = "D:\HAZCode\TakeOut\src\Api\TakeoutSaaS.AdminApi" +$env:TAKEOUTSAAS_APP_CONNECTION = "Host=120.53.222.17;Port=5432;Database=takeout_app_db;Username=app_user;Password=AppUser112233;Pooling=true" +$env:TAKEOUTSAAS_IDENTITY_CONNECTION = "Host=120.53.222.17;Port=5432;Database=takeout_identity_db;Username=identity_user;Password=IdentityUser112233;Pooling=true" +$env:TAKEOUTSAAS_DICTIONARY_CONNECTION = "Host=120.53.222.17;Port=5432;Database=takeout_dictionary_db;Username=dictionary_user;Password=DictionaryUser112233;Pooling=true" +``` + +### Bash + +```bash +export TAKEOUTSAAS_APPSETTINGS_DIR=/home/user/TakeOut/src/Api/TakeoutSaaS.AdminApi +export TAKEOUTSAAS_APP_CONNECTION="Host=120.53.222.17;Port=5432;Database=takeout_app_db;Username=app_user;Password=AppUser112233;Pooling=true" +export TAKEOUTSAAS_IDENTITY_CONNECTION="Host=120.53.222.17;Port=5432;Database=takeout_identity_db;Username=identity_user;Password=IdentityUser112233;Pooling=true" +export TAKEOUTSAAS_DICTIONARY_CONNECTION="Host=120.53.222.17;Port=5432;Database=takeout_dictionary_db;Username=dictionary_user;Password=DictionaryUser112233;Pooling=true" +``` + +Redis 连接字符串直接写入 `appsettings.*.json` 即可,如: + +```jsonc +"Redis": "49.232.6.45:6379,password=MsuMshk112233,abortConnect=false" +``` + +## 4. 运维指南 + +### PostgreSQL + +1. **只读账号验证** + ```powershell + psql "host=120.53.222.17 port=5432 dbname=takeout_app_db user=app_user password=AppUser112233" + ``` +2. **备份** + ```bash + pg_dump -h 120.53.222.17 -p 5432 -U postgres -F c -d takeout_app_db -f backup/takeout_app_db_$(date +%Y%m%d).dump + pg_dumpall -h 120.53.222.17 -p 5432 -U postgres > backup/all_$(date +%Y%m%d).sql + ``` +3. **恢复** + ```bash + pg_restore -h 120.53.222.17 -p 5432 -U postgres -d takeout_app_db backup/takeout_app_db_xxx.dump + psql -h 120.53.222.17 -p 5432 -U postgres -f backup/all_yyyymmdd.sql + ``` +4. **账号/权限策略** + - `app_user` / `identity_user` / `dictionary_user` 拥有 `CONNECT`、`TEMP`、Schema `public` 的 CRUD 权限。 + - `hangfire_user` 仅能访问 `takeout_hangfire_db`,不可访问业务库。 + - 创建新表/列时,通过 EF Migration 自动添加 COMMENT。 + +### Redis + +1. **连接验证** + ```bash + redis-cli -h 49.232.6.45 -p 6379 -a MsuMshk112233 ping + ``` +2. **备份** + ```bash + redis-cli -h 49.232.6.45 -p 6379 -a MsuMshk112233 save # 触发 RDB + redis-cli -h 49.232.6.45 -p 6379 -a MsuMshk112233 bgsave # 后台 + ``` + RDB/AOF 文件在服务器 `redis.conf` 定义的目录(默认 `/var/lib/redis`)。 +3. **常见运维项** + - `CONFIG GET dir` / `CONFIG GET dbfilename` 可查看持久化路径。 + - `INFO memory` 监控内存;开启 `maxmemory` + `allkeys-lru` 保护。 + +## 5. IaC / 脚本 + +| 文件 | 说明 | +| --- | --- | +| `deploy/postgres/create_databases.sql` | 基于 `postgres` 管理员执行,创建四个业务库及角色、授予权限、补 COMMENT。 | +| `deploy/postgres/bootstrap.ps1` | PowerShell 包装脚本,调用 `psql` 执行上面的 SQL(默认读取 `postgres` 管理员账号)。 | +| `deploy/postgres/README.md` | 介绍如何在本地/测试环境执行 bootstrap 并校验连接。 | +| `deploy/redis/docker-compose.yml` | 可复用的 Redis 部署(Redis 7 + AOF),便于本地或测试环境一键拉起。 | +| `deploy/redis/redis.conf` | compose/裸机均可共用的配置(`requirepass`、持久化等已写好)。 | +| `deploy/redis/README.md` | 说明如何使用 compose 或将 `redis.conf` 部署到现有实例。 | + +> 线上目前为裸机安装(非容器),如需创建新环境/快速恢复,可直接运行上述脚本达到同样配置;即使在现有机器上,也可把 SQL/配置当作“最终规范”确保环境一致性。 diff --git a/deploy/postgres/README.md b/deploy/postgres/README.md new file mode 100644 index 0000000..04e7222 --- /dev/null +++ b/deploy/postgres/README.md @@ -0,0 +1,47 @@ +# PostgreSQL 部署脚本 + +本目录提供在测试/预发布环境快速拉起 PostgreSQL 的脚本,复用线上同名数据库与账号,方便迁移/恢复。 + +## 目录结构 + +- `create_databases.sql`:创建四个业务库与对应角色(可多次执行,存在则跳过)。 +- `bootstrap.ps1`:PowerShell 包装脚本,调用 `psql` 执行 SQL。 + +## 前置条件 + +1. 已安装 PostgreSQL 12+,并能以管理员身份访问(默认使用 `postgres`)。 +2. 本地已配置 `psql` 可执行命令。 + +## 使用方法 + +```powershell +cd deploy/postgres +.\bootstrap.ps1 ` + -Host 120.53.222.17 ` + -Port 5432 ` + -AdminUser postgres ` + -AdminPassword "超级管理员密码" +``` + +脚本会: + +1. 创建/更新以下角色与库: + - `app_user` / `takeout_app_db` + - `identity_user` / `takeout_identity_db` + - `dictionary_user` / `takeout_dictionary_db` + - `hangfire_user` / `takeout_hangfire_db` +2. 为库设置 COMMENT,授予 Schema `public` 的 CRUD 权限。 +3. 输出执行日志,失败时终止。 + +## 自定义 + +- 如需修改密码或新增库,编辑 `create_databases.sql` 后重新运行脚本。 +- 若在本地拉起测试库,可把 `Host` 指向 `localhost`,其余参数保持一致。 + +## 常见问题 + +| 问题 | 处理方式 | +| --- | --- | +| `psql : command not found` | 确认 PostgreSQL bin 目录已加入 PATH。 | +| `permission denied to create database` | 改用具有 `CREATEDB` 权限的管理员执行脚本。 | +| 需要删除库 | 先 `DROP DATABASE xxx`,再运行脚本重新创建。 | diff --git a/deploy/postgres/bootstrap.ps1 b/deploy/postgres/bootstrap.ps1 new file mode 100644 index 0000000..3ea0bea --- /dev/null +++ b/deploy/postgres/bootstrap.ps1 @@ -0,0 +1,37 @@ +param( + [string]$Host = "120.53.222.17", + [int]$Port = 5432, + [string]$AdminUser = "postgres", + [string]$AdminPassword = "" +) + +if (-not (Get-Command psql -ErrorAction SilentlyContinue)) { + throw "psql command not found. Add PostgreSQL bin directory to PATH." +} + +if ([string]::IsNullOrWhiteSpace($AdminPassword)) { + Write-Warning "AdminPassword not provided. You will be prompted by psql." +} + +$sqlPath = Join-Path $PSScriptRoot "create_databases.sql" +if (-not (Test-Path $sqlPath)) { + throw "Cannot find create_databases.sql under $PSScriptRoot." +} + +$env:PGPASSWORD = $AdminPassword + +$arguments = @( + "-h", $Host, + "-p", $Port, + "-U", $AdminUser, + "-f", $sqlPath +) + +Write-Host "Executing create_databases.sql on $Host:$Port as $AdminUser ..." +& psql @arguments + +if ($LASTEXITCODE -ne 0) { + throw "psql returned non-zero exit code ($LASTEXITCODE)." +} + +Write-Host "PostgreSQL databases and roles ensured successfully." diff --git a/deploy/postgres/create_databases.sql b/deploy/postgres/create_databases.sql new file mode 100644 index 0000000..c8732f6 --- /dev/null +++ b/deploy/postgres/create_databases.sql @@ -0,0 +1,83 @@ +-- Reusable provisioning script for Takeout SaaS PostgreSQL databases. +-- Execute with a superuser (e.g. postgres). Safe to re-run. + +DO $$ +BEGIN + IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'app_user') THEN + CREATE ROLE app_user LOGIN PASSWORD 'AppUser112233'; + END IF; + IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'identity_user') THEN + CREATE ROLE identity_user LOGIN PASSWORD 'IdentityUser112233'; + END IF; + IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'dictionary_user') THEN + CREATE ROLE dictionary_user LOGIN PASSWORD 'DictionaryUser112233'; + END IF; + IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'hangfire_user') THEN + CREATE ROLE hangfire_user LOGIN PASSWORD 'HangFire112233'; + END IF; +END $$; + +DO $$ +BEGIN + IF NOT EXISTS (SELECT 1 FROM pg_database WHERE datname = 'takeout_app_db') THEN + CREATE DATABASE takeout_app_db OWNER app_user ENCODING 'UTF8'; + END IF; +END $$; +COMMENT ON DATABASE takeout_app_db IS 'Takeout SaaS 业务域数据库'; + +DO $$ +BEGIN + IF NOT EXISTS (SELECT 1 FROM pg_database WHERE datname = 'takeout_identity_db') THEN + CREATE DATABASE takeout_identity_db OWNER identity_user ENCODING 'UTF8'; + END IF; +END $$; +COMMENT ON DATABASE takeout_identity_db IS 'Takeout SaaS 身份域数据库'; + +DO $$ +BEGIN + IF NOT EXISTS (SELECT 1 FROM pg_database WHERE datname = 'takeout_dictionary_db') THEN + CREATE DATABASE takeout_dictionary_db OWNER dictionary_user ENCODING 'UTF8'; + END IF; +END $$; +COMMENT ON DATABASE takeout_dictionary_db IS 'Takeout SaaS 字典域数据库'; + +DO $$ +BEGIN + IF NOT EXISTS (SELECT 1 FROM pg_database WHERE datname = 'takeout_hangfire_db') THEN + CREATE DATABASE takeout_hangfire_db OWNER hangfire_user ENCODING 'UTF8'; + END IF; +END $$; +COMMENT ON DATABASE takeout_hangfire_db IS 'Takeout SaaS 调度/Hangfire 数据库'; + +-- Ensure privileges and default schema permissions +\connect takeout_app_db +GRANT CONNECT, TEMP ON DATABASE takeout_app_db TO app_user; +GRANT USAGE ON SCHEMA public TO app_user; +GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO app_user; +GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA public TO app_user; +ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO app_user; +ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT USAGE, SELECT, UPDATE ON SEQUENCES TO app_user; + +\connect takeout_identity_db +GRANT CONNECT, TEMP ON DATABASE takeout_identity_db TO identity_user; +GRANT USAGE ON SCHEMA public TO identity_user; +GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO identity_user; +GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA public TO identity_user; +ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO identity_user; +ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT USAGE, SELECT, UPDATE ON SEQUENCES TO identity_user; + +\connect takeout_dictionary_db +GRANT CONNECT, TEMP ON DATABASE takeout_dictionary_db TO dictionary_user; +GRANT USAGE ON SCHEMA public TO dictionary_user; +GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO dictionary_user; +GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA public TO dictionary_user; +ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO dictionary_user; +ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT USAGE, SELECT, UPDATE ON SEQUENCES TO dictionary_user; + +\connect takeout_hangfire_db +GRANT CONNECT, TEMP ON DATABASE takeout_hangfire_db TO hangfire_user; +GRANT USAGE ON SCHEMA public TO hangfire_user; +GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO hangfire_user; +GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA public TO hangfire_user; +ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO hangfire_user; +ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT USAGE, SELECT, UPDATE ON SEQUENCES TO hangfire_user; diff --git a/deploy/redis/README.md b/deploy/redis/README.md new file mode 100644 index 0000000..c955032 --- /dev/null +++ b/deploy/redis/README.md @@ -0,0 +1,34 @@ +# Redis 部署脚本 + +本目录提供可复用的 Redis 配置,既可在本地通过 Docker Compose 启动,也可将 `redis.conf` 拷贝到现有服务器,确保与线上一致。 + +## 1. 部署步骤 (裸机)\n\n1. 将 \\ edis.conf\\ 拷贝到服务器(例如 /etc/redis/redis.conf)。\n2. 根据需要修改数据目录(\\dir\\)和绑定地址。\n3. 使用系统服务或 \\ edis-server redis.conf\\ 启动。\n4. 确认开放端口 6379,保证通过 \\ edis-cli -h -a ping\\ 可访问。\n\n## 2. 配置说明\n\n- \\ equirepass\\ 已设置为 MsuMshk112233。\n- 启用 appendonly(AOF),并每秒 fsync。\n- \\maxmemory-policy\\ 为 allkeys-lru,适合缓存场景。\n- \\protected-mode no\\ 允许远程连接,需结合安全组或防火墙限制来源 IP。\n\n## 3. 常用命令使用 `redis.conf` + +1. 把 `redis.conf` 拷贝到服务器 `/etc/redis/redis.conf`(或自定义目录)。 +2. 修改 `dir` 指向实际数据目录。 +3. 使用系统服务或 `redis-server redis.conf` 启动。 + +关键配置已包含: + +- `requirepass`(密码) +- `protected-mode no`(允许远程连接) +- `appendonly yes` + `appendfsync everysec` +- `maxmemory-policy allkeys-lru` + +## 3. 常用命令 + +在应用或 CLI 中使用: + +```bash +redis-cli -h 49.232.6.45 -p 6379 -a MsuMshk112233 ping +``` + +`appsettings.*.json` 的格式:`"Redis": "49.232.6.45:6379,password=MsuMshk112233,abortConnect=false"` + +## 4. 备份 + +- RDB 文件:`dump.rdb` +- AOF 文件:`appendonly.aof` + +通过 `redis-cli -a save` 或 `bgsave` 触发。确保备份目录已纳入快照/对象存储。 + diff --git a/deploy/redis/redis.conf b/deploy/redis/redis.conf new file mode 100644 index 0000000..5d20bb0 --- /dev/null +++ b/deploy/redis/redis.conf @@ -0,0 +1,25 @@ +bind 0.0.0.0 +port 6379 +protected-mode no + +requirepass MsuMshk112233 + +timeout 0 +tcp-keepalive 300 + +daemonize no + +loglevel notice +databases 16 + +save 900 1 +save 300 10 +save 60 10000 + +appendonly yes +appendfilename "appendonly.aof" +appendfsync everysec + +dir /data + +maxmemory-policy allkeys-lru diff --git a/src/Api/TakeoutSaaS.AdminApi/appsettings.Development.json b/src/Api/TakeoutSaaS.AdminApi/appsettings.Development.json index d858ad3..6762606 100644 --- a/src/Api/TakeoutSaaS.AdminApi/appsettings.Development.json +++ b/src/Api/TakeoutSaaS.AdminApi/appsettings.Development.json @@ -2,18 +2,27 @@ "Database": { "DataSources": { "AppDatabase": { - "Write": "Host=120.53.222.17;Port=5432;Database=takeout_saas_app;Username=app_user;Password=MsuMshk112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", + "Write": "Host=120.53.222.17;Port=5432;Database=takeout_app_db;Username=app_user;Password=AppUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", "Reads": [ - "Host=120.53.222.17;Port=5432;Database=takeout_saas_app;Username=app_user;Password=MsuMshk112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50" + "Host=120.53.222.17;Port=5432;Database=takeout_app_db;Username=app_user;Password=AppUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50" ], "CommandTimeoutSeconds": 30, "MaxRetryCount": 3, "MaxRetryDelaySeconds": 5 }, "IdentityDatabase": { - "Write": "Host=120.53.222.17;Port=5432;Database=takeout_saas_identity;Username=identity_user;Password=MsuMshk112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", + "Write": "Host=120.53.222.17;Port=5432;Database=takeout_identity_db;Username=identity_user;Password=IdentityUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", "Reads": [ - "Host=120.53.222.17;Port=5432;Database=takeout_saas_identity;Username=identity_user;Password=MsuMshk112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50" + "Host=120.53.222.17;Port=5432;Database=takeout_identity_db;Username=identity_user;Password=IdentityUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50" + ], + "CommandTimeoutSeconds": 30, + "MaxRetryCount": 3, + "MaxRetryDelaySeconds": 5 + }, + "DictionaryDatabase": { + "Write": "Host=120.53.222.17;Port=5432;Database=takeout_dictionary_db;Username=dictionary_user;Password=DictionaryUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", + "Reads": [ + "Host=120.53.222.17;Port=5432;Database=takeout_dictionary_db;Username=dictionary_user;Password=DictionaryUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50" ], "CommandTimeoutSeconds": 30, "MaxRetryCount": 3, @@ -134,7 +143,7 @@ "PrefetchCount": 20 }, "Scheduler": { - "ConnectionString": "Host=120.53.222.17;Port=5432;Database=takeout_saas_hangfire;Username=app_user;Password=MsuMshk112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", + "ConnectionString": "Host=120.53.222.17;Port=5432;Database=takeout_hangfire_db;Username=hangfire_user;Password=HangFire112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", "WorkerCount": 5, "DashboardEnabled": false, "DashboardPath": "/hangfire" diff --git a/src/Api/TakeoutSaaS.AdminApi/appsettings.Production.json b/src/Api/TakeoutSaaS.AdminApi/appsettings.Production.json index d858ad3..6762606 100644 --- a/src/Api/TakeoutSaaS.AdminApi/appsettings.Production.json +++ b/src/Api/TakeoutSaaS.AdminApi/appsettings.Production.json @@ -2,18 +2,27 @@ "Database": { "DataSources": { "AppDatabase": { - "Write": "Host=120.53.222.17;Port=5432;Database=takeout_saas_app;Username=app_user;Password=MsuMshk112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", + "Write": "Host=120.53.222.17;Port=5432;Database=takeout_app_db;Username=app_user;Password=AppUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", "Reads": [ - "Host=120.53.222.17;Port=5432;Database=takeout_saas_app;Username=app_user;Password=MsuMshk112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50" + "Host=120.53.222.17;Port=5432;Database=takeout_app_db;Username=app_user;Password=AppUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50" ], "CommandTimeoutSeconds": 30, "MaxRetryCount": 3, "MaxRetryDelaySeconds": 5 }, "IdentityDatabase": { - "Write": "Host=120.53.222.17;Port=5432;Database=takeout_saas_identity;Username=identity_user;Password=MsuMshk112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", + "Write": "Host=120.53.222.17;Port=5432;Database=takeout_identity_db;Username=identity_user;Password=IdentityUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", "Reads": [ - "Host=120.53.222.17;Port=5432;Database=takeout_saas_identity;Username=identity_user;Password=MsuMshk112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50" + "Host=120.53.222.17;Port=5432;Database=takeout_identity_db;Username=identity_user;Password=IdentityUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50" + ], + "CommandTimeoutSeconds": 30, + "MaxRetryCount": 3, + "MaxRetryDelaySeconds": 5 + }, + "DictionaryDatabase": { + "Write": "Host=120.53.222.17;Port=5432;Database=takeout_dictionary_db;Username=dictionary_user;Password=DictionaryUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", + "Reads": [ + "Host=120.53.222.17;Port=5432;Database=takeout_dictionary_db;Username=dictionary_user;Password=DictionaryUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50" ], "CommandTimeoutSeconds": 30, "MaxRetryCount": 3, @@ -134,7 +143,7 @@ "PrefetchCount": 20 }, "Scheduler": { - "ConnectionString": "Host=120.53.222.17;Port=5432;Database=takeout_saas_hangfire;Username=app_user;Password=MsuMshk112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", + "ConnectionString": "Host=120.53.222.17;Port=5432;Database=takeout_hangfire_db;Username=hangfire_user;Password=HangFire112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", "WorkerCount": 5, "DashboardEnabled": false, "DashboardPath": "/hangfire" diff --git a/src/Api/TakeoutSaaS.MiniApi/appsettings.Development.json b/src/Api/TakeoutSaaS.MiniApi/appsettings.Development.json index 0d6da09..3b288cf 100644 --- a/src/Api/TakeoutSaaS.MiniApi/appsettings.Development.json +++ b/src/Api/TakeoutSaaS.MiniApi/appsettings.Development.json @@ -2,18 +2,27 @@ "Database": { "DataSources": { "AppDatabase": { - "Write": "Host=120.53.222.17;Port=5432;Database=takeout_saas_app;Username=app_user;Password=MsuMshk112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", + "Write": "Host=120.53.222.17;Port=5432;Database=takeout_app_db;Username=app_user;Password=AppUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", "Reads": [ - "Host=120.53.222.17;Port=5432;Database=takeout_saas_app;Username=app_user;Password=MsuMshk112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50" + "Host=120.53.222.17;Port=5432;Database=takeout_app_db;Username=app_user;Password=AppUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50" ], "CommandTimeoutSeconds": 30, "MaxRetryCount": 3, "MaxRetryDelaySeconds": 5 }, "IdentityDatabase": { - "Write": "Host=120.53.222.17;Port=5432;Database=takeout_saas_identity;Username=identity_user;Password=MsuMshk112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", + "Write": "Host=120.53.222.17;Port=5432;Database=takeout_identity_db;Username=identity_user;Password=IdentityUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", "Reads": [ - "Host=120.53.222.17;Port=5432;Database=takeout_saas_identity;Username=identity_user;Password=MsuMshk112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50" + "Host=120.53.222.17;Port=5432;Database=takeout_identity_db;Username=identity_user;Password=IdentityUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50" + ], + "CommandTimeoutSeconds": 30, + "MaxRetryCount": 3, + "MaxRetryDelaySeconds": 5 + }, + "DictionaryDatabase": { + "Write": "Host=120.53.222.17;Port=5432;Database=takeout_dictionary_db;Username=dictionary_user;Password=DictionaryUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", + "Reads": [ + "Host=120.53.222.17;Port=5432;Database=takeout_dictionary_db;Username=dictionary_user;Password=DictionaryUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50" ], "CommandTimeoutSeconds": 30, "MaxRetryCount": 3, diff --git a/src/Api/TakeoutSaaS.MiniApi/appsettings.Production.json b/src/Api/TakeoutSaaS.MiniApi/appsettings.Production.json index 0d6da09..3b288cf 100644 --- a/src/Api/TakeoutSaaS.MiniApi/appsettings.Production.json +++ b/src/Api/TakeoutSaaS.MiniApi/appsettings.Production.json @@ -2,18 +2,27 @@ "Database": { "DataSources": { "AppDatabase": { - "Write": "Host=120.53.222.17;Port=5432;Database=takeout_saas_app;Username=app_user;Password=MsuMshk112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", + "Write": "Host=120.53.222.17;Port=5432;Database=takeout_app_db;Username=app_user;Password=AppUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", "Reads": [ - "Host=120.53.222.17;Port=5432;Database=takeout_saas_app;Username=app_user;Password=MsuMshk112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50" + "Host=120.53.222.17;Port=5432;Database=takeout_app_db;Username=app_user;Password=AppUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50" ], "CommandTimeoutSeconds": 30, "MaxRetryCount": 3, "MaxRetryDelaySeconds": 5 }, "IdentityDatabase": { - "Write": "Host=120.53.222.17;Port=5432;Database=takeout_saas_identity;Username=identity_user;Password=MsuMshk112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", + "Write": "Host=120.53.222.17;Port=5432;Database=takeout_identity_db;Username=identity_user;Password=IdentityUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", "Reads": [ - "Host=120.53.222.17;Port=5432;Database=takeout_saas_identity;Username=identity_user;Password=MsuMshk112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50" + "Host=120.53.222.17;Port=5432;Database=takeout_identity_db;Username=identity_user;Password=IdentityUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50" + ], + "CommandTimeoutSeconds": 30, + "MaxRetryCount": 3, + "MaxRetryDelaySeconds": 5 + }, + "DictionaryDatabase": { + "Write": "Host=120.53.222.17;Port=5432;Database=takeout_dictionary_db;Username=dictionary_user;Password=DictionaryUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", + "Reads": [ + "Host=120.53.222.17;Port=5432;Database=takeout_dictionary_db;Username=dictionary_user;Password=DictionaryUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50" ], "CommandTimeoutSeconds": 30, "MaxRetryCount": 3, diff --git a/src/Api/TakeoutSaaS.UserApi/appsettings.Development.json b/src/Api/TakeoutSaaS.UserApi/appsettings.Development.json index 1f7ff9f..7a3af9b 100644 --- a/src/Api/TakeoutSaaS.UserApi/appsettings.Development.json +++ b/src/Api/TakeoutSaaS.UserApi/appsettings.Development.json @@ -2,18 +2,27 @@ "Database": { "DataSources": { "AppDatabase": { - "Write": "Host=120.53.222.17;Port=5432;Database=takeout_saas_app;Username=app_user;Password=MsuMshk112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", + "Write": "Host=120.53.222.17;Port=5432;Database=takeout_app_db;Username=app_user;Password=AppUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", "Reads": [ - "Host=120.53.222.17;Port=5432;Database=takeout_saas_app;Username=app_user;Password=MsuMshk112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50" + "Host=120.53.222.17;Port=5432;Database=takeout_app_db;Username=app_user;Password=AppUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50" ], "CommandTimeoutSeconds": 30, "MaxRetryCount": 3, "MaxRetryDelaySeconds": 5 }, "IdentityDatabase": { - "Write": "Host=120.53.222.17;Port=5432;Database=takeout_saas_identity;Username=identity_user;Password=MsuMshk112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", + "Write": "Host=120.53.222.17;Port=5432;Database=takeout_identity_db;Username=identity_user;Password=IdentityUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", "Reads": [ - "Host=120.53.222.17;Port=5432;Database=takeout_saas_identity;Username=identity_user;Password=MsuMshk112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50" + "Host=120.53.222.17;Port=5432;Database=takeout_identity_db;Username=identity_user;Password=IdentityUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50" + ], + "CommandTimeoutSeconds": 30, + "MaxRetryCount": 3, + "MaxRetryDelaySeconds": 5 + }, + "DictionaryDatabase": { + "Write": "Host=120.53.222.17;Port=5432;Database=takeout_dictionary_db;Username=dictionary_user;Password=DictionaryUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", + "Reads": [ + "Host=120.53.222.17;Port=5432;Database=takeout_dictionary_db;Username=dictionary_user;Password=DictionaryUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50" ], "CommandTimeoutSeconds": 30, "MaxRetryCount": 3, diff --git a/src/Api/TakeoutSaaS.UserApi/appsettings.Production.json b/src/Api/TakeoutSaaS.UserApi/appsettings.Production.json index 1f7ff9f..7a3af9b 100644 --- a/src/Api/TakeoutSaaS.UserApi/appsettings.Production.json +++ b/src/Api/TakeoutSaaS.UserApi/appsettings.Production.json @@ -2,18 +2,27 @@ "Database": { "DataSources": { "AppDatabase": { - "Write": "Host=120.53.222.17;Port=5432;Database=takeout_saas_app;Username=app_user;Password=MsuMshk112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", + "Write": "Host=120.53.222.17;Port=5432;Database=takeout_app_db;Username=app_user;Password=AppUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", "Reads": [ - "Host=120.53.222.17;Port=5432;Database=takeout_saas_app;Username=app_user;Password=MsuMshk112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50" + "Host=120.53.222.17;Port=5432;Database=takeout_app_db;Username=app_user;Password=AppUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50" ], "CommandTimeoutSeconds": 30, "MaxRetryCount": 3, "MaxRetryDelaySeconds": 5 }, "IdentityDatabase": { - "Write": "Host=120.53.222.17;Port=5432;Database=takeout_saas_identity;Username=identity_user;Password=MsuMshk112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", + "Write": "Host=120.53.222.17;Port=5432;Database=takeout_identity_db;Username=identity_user;Password=IdentityUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", "Reads": [ - "Host=120.53.222.17;Port=5432;Database=takeout_saas_identity;Username=identity_user;Password=MsuMshk112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50" + "Host=120.53.222.17;Port=5432;Database=takeout_identity_db;Username=identity_user;Password=IdentityUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50" + ], + "CommandTimeoutSeconds": 30, + "MaxRetryCount": 3, + "MaxRetryDelaySeconds": 5 + }, + "DictionaryDatabase": { + "Write": "Host=120.53.222.17;Port=5432;Database=takeout_dictionary_db;Username=dictionary_user;Password=DictionaryUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50", + "Reads": [ + "Host=120.53.222.17;Port=5432;Database=takeout_dictionary_db;Username=dictionary_user;Password=DictionaryUser112233;Pooling=true;Minimum Pool Size=5;Maximum Pool Size=50" ], "CommandTimeoutSeconds": 30, "MaxRetryCount": 3, diff --git a/src/Core/TakeoutSaaS.Shared.Abstractions/Constants/DatabaseConstants.cs b/src/Core/TakeoutSaaS.Shared.Abstractions/Constants/DatabaseConstants.cs index 6fe8a35..cc18844 100644 --- a/src/Core/TakeoutSaaS.Shared.Abstractions/Constants/DatabaseConstants.cs +++ b/src/Core/TakeoutSaaS.Shared.Abstractions/Constants/DatabaseConstants.cs @@ -14,4 +14,9 @@ public static class DatabaseConstants /// 身份认证库(IdentityDatabase)。 /// public const string IdentityDataSource = "IdentityDatabase"; + + /// + /// �����ֵ�⣨DictionaryDatabase���� + /// + public const string DictionaryDataSource = "DictionaryDatabase"; } diff --git a/src/Core/TakeoutSaaS.Shared.Abstractions/TakeoutSaaS.Shared.Abstractions.csproj b/src/Core/TakeoutSaaS.Shared.Abstractions/TakeoutSaaS.Shared.Abstractions.csproj index 05f0387..2de50de 100644 --- a/src/Core/TakeoutSaaS.Shared.Abstractions/TakeoutSaaS.Shared.Abstractions.csproj +++ b/src/Core/TakeoutSaaS.Shared.Abstractions/TakeoutSaaS.Shared.Abstractions.csproj @@ -3,6 +3,8 @@ net10.0 enable enable + true + 1591 diff --git a/src/Domain/TakeoutSaaS.Domain/TakeoutSaaS.Domain.csproj b/src/Domain/TakeoutSaaS.Domain/TakeoutSaaS.Domain.csproj index b407eac..3f9021d 100644 --- a/src/Domain/TakeoutSaaS.Domain/TakeoutSaaS.Domain.csproj +++ b/src/Domain/TakeoutSaaS.Domain/TakeoutSaaS.Domain.csproj @@ -3,6 +3,8 @@ net10.0 enable enable + true + 1591 diff --git a/src/Infrastructure/TakeoutSaaS.Infrastructure/App/Migrations/20251201055852_ExpandDomainSchema.Designer.cs b/src/Infrastructure/TakeoutSaaS.Infrastructure/App/Migrations/20251201055852_ExpandDomainSchema.Designer.cs new file mode 100644 index 0000000..c901204 --- /dev/null +++ b/src/Infrastructure/TakeoutSaaS.Infrastructure/App/Migrations/20251201055852_ExpandDomainSchema.Designer.cs @@ -0,0 +1,4330 @@ +// +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.App.Persistence; + +#nullable disable + +namespace TakeoutSaaS.Infrastructure.App.Migrations +{ + [DbContext(typeof(TakeoutAppDbContext))] + [Migration("20251201055852_ExpandDomainSchema")] + partial class ExpandDomainSchema + { + /// + 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.Analytics.Entities.MetricAlertRule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ConditionJson") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("Enabled") + .HasColumnType("boolean"); + + b.Property("MetricDefinitionId") + .HasColumnType("uuid"); + + b.Property("NotificationChannels") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("Severity") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "MetricDefinitionId", "Severity"); + + b.ToTable("metric_alert_rules", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Analytics.Entities.MetricDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DefaultAggregation") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("Description") + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.Property("DimensionsJson") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Code") + .IsUnique(); + + b.ToTable("metric_definitions", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Analytics.Entities.MetricSnapshot", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("DimensionKey") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("MetricDefinitionId") + .HasColumnType("uuid"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.Property("Value") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("WindowEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("WindowStart") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "MetricDefinitionId", "DimensionKey", "WindowStart", "WindowEnd") + .IsUnique(); + + b.ToTable("metric_snapshots", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Coupons.Entities.Coupon", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("CouponTemplateId") + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("ExpireAt") + .HasColumnType("timestamp with time zone"); + + b.Property("IssuedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("OrderId") + .HasColumnType("uuid"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.Property("UsedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Code") + .IsUnique(); + + b.ToTable("coupons", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Coupons.Entities.CouponTemplate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AllowStack") + .HasColumnType("boolean"); + + b.Property("ChannelsJson") + .HasColumnType("text"); + + b.Property("ClaimedQuantity") + .HasColumnType("integer"); + + b.Property("CouponType") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("Description") + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.Property("DiscountCap") + .HasColumnType("numeric"); + + b.Property("MinimumSpend") + .HasColumnType("numeric"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("ProductScopeJson") + .HasColumnType("text"); + + b.Property("RelativeValidDays") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("StoreScopeJson") + .HasColumnType("text"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("TotalQuantity") + .HasColumnType("integer"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.Property("ValidFrom") + .HasColumnType("timestamp with time zone"); + + b.Property("ValidTo") + .HasColumnType("timestamp with time zone"); + + b.Property("Value") + .HasColumnType("numeric"); + + b.HasKey("Id"); + + b.ToTable("coupon_templates", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Coupons.Entities.PromotionCampaign", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AudienceDescription") + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.Property("BannerUrl") + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.Property("Budget") + .HasColumnType("numeric"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("EndAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("PromotionType") + .HasColumnType("integer"); + + b.Property("RulesJson") + .IsRequired() + .HasColumnType("text"); + + b.Property("StartAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.ToTable("promotion_campaigns", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.CustomerService.Entities.ChatMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ChatSessionId") + .HasColumnType("uuid"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("character varying(1024)"); + + b.Property("ContentType") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("IsRead") + .HasColumnType("boolean"); + + b.Property("ReadAt") + .HasColumnType("timestamp with time zone"); + + b.Property("SenderType") + .HasColumnType("integer"); + + b.Property("SenderUserId") + .HasColumnType("uuid"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "ChatSessionId", "CreatedAt"); + + b.ToTable("chat_messages", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.CustomerService.Entities.ChatSession", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AgentUserId") + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CustomerUserId") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("EndedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("IsBotActive") + .HasColumnType("boolean"); + + b.Property("SessionCode") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("StartedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("StoreId") + .HasColumnType("uuid"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "SessionCode") + .IsUnique(); + + b.ToTable("chat_sessions", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.CustomerService.Entities.SupportTicket", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AssignedAgentId") + .HasColumnType("uuid"); + + b.Property("ClosedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CustomerUserId") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("OrderId") + .HasColumnType("uuid"); + + b.Property("Priority") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("Subject") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("TicketNo") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "TicketNo") + .IsUnique(); + + b.ToTable("support_tickets", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.CustomerService.Entities.TicketComment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AttachmentsJson") + .HasColumnType("text"); + + b.Property("AuthorUserId") + .HasColumnType("uuid"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("character varying(1024)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("IsInternal") + .HasColumnType("boolean"); + + b.Property("SupportTicketId") + .HasColumnType("uuid"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "SupportTicketId"); + + b.ToTable("ticket_comments", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Deliveries.Entities.DeliveryEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("DeliveryOrderId") + .HasColumnType("uuid"); + + b.Property("EventType") + .HasColumnType("integer"); + + b.Property("Message") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("OccurredAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Payload") + .HasColumnType("text"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "DeliveryOrderId", "EventType"); + + b.ToTable("delivery_events", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Deliveries.Entities.DeliveryOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CourierName") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CourierPhone") + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("DeliveredAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeliveryFee") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("DispatchedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("FailureReason") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("OrderId") + .HasColumnType("uuid"); + + b.Property("PickedUpAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Provider") + .HasColumnType("integer"); + + b.Property("ProviderOrderId") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "OrderId") + .IsUnique(); + + b.ToTable("delivery_orders", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Distribution.Entities.AffiliateOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AffiliatePartnerId") + .HasColumnType("uuid"); + + b.Property("BuyerUserId") + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("EstimatedCommission") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("OrderAmount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("OrderId") + .HasColumnType("uuid"); + + b.Property("SettledAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "AffiliatePartnerId", "OrderId") + .IsUnique(); + + b.ToTable("affiliate_orders", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Distribution.Entities.AffiliatePartner", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ChannelType") + .HasColumnType("integer"); + + b.Property("CommissionRate") + .HasColumnType("numeric"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("Phone") + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("Remarks") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "DisplayName"); + + b.ToTable("affiliate_partners", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Distribution.Entities.AffiliatePayout", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AffiliatePartnerId") + .HasColumnType("uuid"); + + b.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("PaidAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Period") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("Remarks") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "AffiliatePartnerId", "Period") + .IsUnique(); + + b.ToTable("affiliate_payouts", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Engagement.Entities.CheckInCampaign", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AllowMakeupCount") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("Description") + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.Property("EndDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("RewardsJson") + .IsRequired() + .HasColumnType("text"); + + b.Property("StartDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Name"); + + b.ToTable("checkin_campaigns", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Engagement.Entities.CheckInRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CheckInCampaignId") + .HasColumnType("uuid"); + + b.Property("CheckInDate") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("IsMakeup") + .HasColumnType("boolean"); + + b.Property("RewardJson") + .IsRequired() + .HasColumnType("text"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "CheckInCampaignId", "UserId", "CheckInDate") + .IsUnique(); + + b.ToTable("checkin_records", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Engagement.Entities.CommunityComment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AuthorUserId") + .HasColumnType("uuid"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("ParentId") + .HasColumnType("uuid"); + + b.Property("PostId") + .HasColumnType("uuid"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "PostId", "CreatedAt"); + + b.ToTable("community_comments", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Engagement.Entities.CommunityPost", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AuthorUserId") + .HasColumnType("uuid"); + + b.Property("CommentCount") + .HasColumnType("integer"); + + b.Property("Content") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("LikeCount") + .HasColumnType("integer"); + + b.Property("MediaJson") + .HasColumnType("text"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("Title") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "AuthorUserId", "CreatedAt"); + + b.ToTable("community_posts", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Engagement.Entities.CommunityReaction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("PostId") + .HasColumnType("uuid"); + + b.Property("ReactedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ReactionType") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "PostId", "UserId") + .IsUnique(); + + b.ToTable("community_reactions", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.GroupBuying.Entities.GroupOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CancelledAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CurrentCount") + .HasColumnType("integer"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("EndAt") + .HasColumnType("timestamp with time zone"); + + b.Property("GroupOrderNo") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("GroupPrice") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("LeaderUserId") + .HasColumnType("uuid"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("StartAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("StoreId") + .HasColumnType("uuid"); + + b.Property("SucceededAt") + .HasColumnType("timestamp with time zone"); + + b.Property("TargetCount") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "GroupOrderNo") + .IsUnique(); + + b.ToTable("group_orders", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.GroupBuying.Entities.GroupParticipant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("GroupOrderId") + .HasColumnType("uuid"); + + b.Property("JoinedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("OrderId") + .HasColumnType("uuid"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "GroupOrderId", "UserId") + .IsUnique(); + + b.ToTable("group_participants", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Inventory.Entities.InventoryAdjustment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AdjustmentType") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("InventoryItemId") + .HasColumnType("uuid"); + + b.Property("OccurredAt") + .HasColumnType("timestamp with time zone"); + + b.Property("OperatorId") + .HasColumnType("uuid"); + + b.Property("Quantity") + .HasColumnType("integer"); + + b.Property("Reason") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "InventoryItemId", "OccurredAt"); + + b.ToTable("inventory_adjustments", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Inventory.Entities.InventoryBatch", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("BatchNumber") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("ExpireDate") + .HasColumnType("timestamp with time zone"); + + b.Property("ProductSkuId") + .HasColumnType("uuid"); + + b.Property("ProductionDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Quantity") + .HasColumnType("integer"); + + b.Property("RemainingQuantity") + .HasColumnType("integer"); + + b.Property("StoreId") + .HasColumnType("uuid"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId", "ProductSkuId", "BatchNumber") + .IsUnique(); + + b.ToTable("inventory_batches", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Inventory.Entities.InventoryItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("BatchNumber") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("ExpireDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Location") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ProductSkuId") + .HasColumnType("uuid"); + + b.Property("QuantityOnHand") + .HasColumnType("integer"); + + b.Property("QuantityReserved") + .HasColumnType("integer"); + + b.Property("SafetyStock") + .HasColumnType("integer"); + + b.Property("StoreId") + .HasColumnType("uuid"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId", "ProductSkuId", "BatchNumber"); + + b.ToTable("inventory_items", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Membership.Entities.MemberGrowthLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ChangeValue") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CurrentValue") + .HasColumnType("integer"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("MemberId") + .HasColumnType("uuid"); + + b.Property("Notes") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("OccurredAt") + .HasColumnType("timestamp with time zone"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "MemberId", "OccurredAt"); + + b.ToTable("member_growth_logs", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Membership.Entities.MemberPointLedger", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("BalanceAfterChange") + .HasColumnType("integer"); + + b.Property("ChangeAmount") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("ExpireAt") + .HasColumnType("timestamp with time zone"); + + b.Property("MemberId") + .HasColumnType("uuid"); + + b.Property("OccurredAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Reason") + .HasColumnType("integer"); + + b.Property("SourceId") + .HasColumnType("uuid"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "MemberId", "OccurredAt"); + + b.ToTable("member_point_ledgers", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Membership.Entities.MemberProfile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AvatarUrl") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("BirthDate") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("GrowthValue") + .HasColumnType("integer"); + + b.Property("JoinedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("MemberTierId") + .HasColumnType("uuid"); + + b.Property("Mobile") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("Nickname") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("PointsBalance") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Mobile") + .IsUnique(); + + b.ToTable("member_profiles", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Membership.Entities.MemberTier", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("BenefitsJson") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("RequiredGrowth") + .HasColumnType("integer"); + + b.Property("SortOrder") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Name") + .IsUnique(); + + b.ToTable("member_tiers", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Merchants.Entities.Merchant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Address") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("BrandAlias") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("BrandName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("BusinessLicenseImageUrl") + .HasColumnType("text"); + + b.Property("BusinessLicenseNumber") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("Category") + .HasColumnType("text"); + + b.Property("City") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ContactEmail") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("ContactPhone") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("District") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("JoinedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("LastReviewedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Latitude") + .HasColumnType("double precision"); + + b.Property("LegalPerson") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("LogoUrl") + .HasColumnType("text"); + + b.Property("Longitude") + .HasColumnType("double precision"); + + b.Property("Province") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ReviewRemarks") + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.Property("ServicePhone") + .HasColumnType("text"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("SupportEmail") + .HasColumnType("text"); + + b.Property("TaxNumber") + .HasColumnType("text"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId"); + + b.ToTable("merchants", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Merchants.Entities.MerchantContract", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ContractNumber") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("EndDate") + .HasColumnType("timestamp with time zone"); + + b.Property("FileUrl") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.Property("MerchantId") + .HasColumnType("uuid"); + + b.Property("SignedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("StartDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("TerminatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("TerminationReason") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "MerchantId", "ContractNumber") + .IsUnique(); + + b.ToTable("merchant_contracts", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Merchants.Entities.MerchantDocument", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("DocumentNumber") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("DocumentType") + .HasColumnType("integer"); + + b.Property("ExpiresAt") + .HasColumnType("timestamp with time zone"); + + b.Property("FileUrl") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.Property("IssuedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("MerchantId") + .HasColumnType("uuid"); + + b.Property("Remarks") + .HasColumnType("text"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "MerchantId", "DocumentType"); + + b.ToTable("merchant_documents", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Merchants.Entities.MerchantStaff", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("Email") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("IdentityUserId") + .HasColumnType("uuid"); + + b.Property("MerchantId") + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("PermissionsJson") + .HasColumnType("text"); + + b.Property("Phone") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("RoleType") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("StoreId") + .HasColumnType("uuid"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "MerchantId", "Phone"); + + b.ToTable("merchant_staff", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Navigation.Entities.MapLocation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Address") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("Landmark") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Latitude") + .HasColumnType("double precision"); + + b.Property("Longitude") + .HasColumnType("double precision"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("StoreId") + .HasColumnType("uuid"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId"); + + b.ToTable("map_locations", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Navigation.Entities.NavigationRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Channel") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("RequestedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("StoreId") + .HasColumnType("uuid"); + + b.Property("TargetApp") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "UserId", "StoreId", "RequestedAt"); + + b.ToTable("navigation_requests", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Ordering.Entities.CartItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AttributesJson") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("ProductName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("ProductSkuId") + .HasColumnType("uuid"); + + b.Property("Quantity") + .HasColumnType("integer"); + + b.Property("Remark") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("ShoppingCartId") + .HasColumnType("uuid"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UnitPrice") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "ShoppingCartId"); + + b.ToTable("cart_items", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Ordering.Entities.CartItemAddon", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CartItemId") + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("ExtraPrice") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("OptionId") + .HasColumnType("uuid"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.ToTable("cart_item_addons", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Ordering.Entities.CheckoutSession", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("ExpiresAt") + .HasColumnType("timestamp with time zone"); + + b.Property("SessionToken") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("StoreId") + .HasColumnType("uuid"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("ValidationResultJson") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "SessionToken") + .IsUnique(); + + b.ToTable("checkout_sessions", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Ordering.Entities.ShoppingCart", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("DeliveryPreference") + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("LastModifiedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("StoreId") + .HasColumnType("uuid"); + + b.Property("TableContext") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "UserId", "StoreId") + .IsUnique(); + + b.ToTable("shopping_carts", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Orders.Entities.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CancelReason") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("CancelledAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Channel") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CustomerName") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CustomerPhone") + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("DeliveryType") + .HasColumnType("integer"); + + b.Property("DiscountAmount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("FinishedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ItemsAmount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("OrderNo") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("PaidAmount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("PaidAt") + .HasColumnType("timestamp with time zone"); + + b.Property("PayableAmount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("PaymentStatus") + .HasColumnType("integer"); + + b.Property("QueueNumber") + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("Remark") + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.Property("ReservationId") + .HasColumnType("uuid"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("StoreId") + .HasColumnType("uuid"); + + b.Property("TableNo") + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "OrderNo") + .IsUnique(); + + b.HasIndex("TenantId", "StoreId", "Status"); + + b.ToTable("orders", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Orders.Entities.OrderItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AttributesJson") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("DiscountAmount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("OrderId") + .HasColumnType("uuid"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("ProductName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Quantity") + .HasColumnType("integer"); + + b.Property("SkuName") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("SubTotal") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("Unit") + .HasMaxLength(16) + .HasColumnType("character varying(16)"); + + b.Property("UnitPrice") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("TenantId", "OrderId"); + + b.ToTable("order_items", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Orders.Entities.OrderStatusHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("Notes") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("OccurredAt") + .HasColumnType("timestamp with time zone"); + + b.Property("OperatorId") + .HasColumnType("uuid"); + + b.Property("OrderId") + .HasColumnType("uuid"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "OrderId", "OccurredAt"); + + b.ToTable("order_status_histories", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Orders.Entities.RefundRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("OrderId") + .HasColumnType("uuid"); + + b.Property("ProcessedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("RefundNo") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("RequestedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ReviewNotes") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "RefundNo") + .IsUnique(); + + b.ToTable("refund_requests", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Payments.Entities.PaymentRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("ChannelTransactionId") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("Method") + .HasColumnType("integer"); + + b.Property("OrderId") + .HasColumnType("uuid"); + + b.Property("PaidAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Payload") + .HasColumnType("text"); + + b.Property("Remark") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("TradeNo") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "OrderId"); + + b.ToTable("payment_records", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Payments.Entities.PaymentRefundRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("ChannelRefundId") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CompletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("OrderId") + .HasColumnType("uuid"); + + b.Property("Payload") + .HasColumnType("text"); + + b.Property("PaymentRecordId") + .HasColumnType("uuid"); + + b.Property("RequestedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "PaymentRecordId"); + + b.ToTable("payment_refund_records", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Products.Entities.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.Property("CoverImage") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("EnableDelivery") + .HasColumnType("boolean"); + + b.Property("EnableDineIn") + .HasColumnType("boolean"); + + b.Property("EnablePickup") + .HasColumnType("boolean"); + + b.Property("GalleryImages") + .HasMaxLength(1024) + .HasColumnType("character varying(1024)"); + + b.Property("IsFeatured") + .HasColumnType("boolean"); + + b.Property("MaxQuantityPerOrder") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("OriginalPrice") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("Price") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("SpuCode") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("StockQuantity") + .HasColumnType("integer"); + + b.Property("StoreId") + .HasColumnType("uuid"); + + b.Property("Subtitle") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("Unit") + .HasMaxLength(16) + .HasColumnType("character varying(16)"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "SpuCode") + .IsUnique(); + + b.HasIndex("TenantId", "StoreId"); + + b.ToTable("products", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Products.Entities.ProductAddonGroup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("IsRequired") + .HasColumnType("boolean"); + + b.Property("MaxSelect") + .HasColumnType("integer"); + + b.Property("MinSelect") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SelectionType") + .HasColumnType("integer"); + + b.Property("SortOrder") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "ProductId", "Name"); + + b.ToTable("product_addon_groups", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Products.Entities.ProductAddonOption", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AddonGroupId") + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("ExtraPrice") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("IsDefault") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("SortOrder") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.ToTable("product_addon_options", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Products.Entities.ProductAttributeGroup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("IsRequired") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("SelectionType") + .HasColumnType("integer"); + + b.Property("SortOrder") + .HasColumnType("integer"); + + b.Property("StoreId") + .HasColumnType("uuid"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId", "Name"); + + b.ToTable("product_attribute_groups", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Products.Entities.ProductAttributeOption", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AttributeGroupId") + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("ExtraPrice") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("IsDefault") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("SortOrder") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "AttributeGroupId", "Name") + .IsUnique(); + + b.ToTable("product_attribute_options", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Products.Entities.ProductCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("Description") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("IsEnabled") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("SortOrder") + .HasColumnType("integer"); + + b.Property("StoreId") + .HasColumnType("uuid"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId"); + + b.ToTable("product_categories", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Products.Entities.ProductMediaAsset", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Caption") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("MediaType") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SortOrder") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.Property("Url") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.HasKey("Id"); + + b.ToTable("product_media_assets", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Products.Entities.ProductPricingRule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ConditionsJson") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("EndTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Price") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("RuleType") + .HasColumnType("integer"); + + b.Property("StartTime") + .HasColumnType("timestamp with time zone"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.Property("WeekdaysJson") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "ProductId", "RuleType"); + + b.ToTable("product_pricing_rules", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Products.Entities.ProductSku", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AttributesJson") + .IsRequired() + .HasColumnType("text"); + + b.Property("Barcode") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("OriginalPrice") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("Price") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("SkuCode") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("StockQuantity") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.Property("Weight") + .HasPrecision(10, 3) + .HasColumnType("numeric(10,3)"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "SkuCode") + .IsUnique(); + + b.ToTable("product_skus", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Queues.Entities.QueueTicket", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CalledAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CancelledAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("EstimatedWaitMinutes") + .HasColumnType("integer"); + + b.Property("ExpiredAt") + .HasColumnType("timestamp with time zone"); + + b.Property("PartySize") + .HasColumnType("integer"); + + b.Property("Remark") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("StoreId") + .HasColumnType("uuid"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("TicketNumber") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId"); + + b.HasIndex("TenantId", "StoreId", "TicketNumber") + .IsUnique(); + + b.ToTable("queue_tickets", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Reservations.Entities.Reservation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CancelledAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CheckInCode") + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("CheckedInAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CustomerName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CustomerPhone") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("PeopleCount") + .HasColumnType("integer"); + + b.Property("Remark") + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.Property("ReservationNo") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("ReservationTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("StoreId") + .HasColumnType("uuid"); + + b.Property("TablePreference") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "ReservationNo") + .IsUnique(); + + b.HasIndex("TenantId", "StoreId"); + + b.ToTable("reservations", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Stores.Entities.Store", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Address") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("Announcement") + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.Property("BusinessHours") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("City") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("Country") + .HasColumnType("text"); + + b.Property("CoverImageUrl") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("DeliveryRadiusKm") + .HasPrecision(6, 2) + .HasColumnType("numeric(6,2)"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("District") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("Latitude") + .HasColumnType("double precision"); + + b.Property("Longitude") + .HasColumnType("double precision"); + + b.Property("ManagerName") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("MerchantId") + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Phone") + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("Province") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("SupportsDelivery") + .HasColumnType("boolean"); + + b.Property("SupportsDineIn") + .HasColumnType("boolean"); + + b.Property("SupportsPickup") + .HasColumnType("boolean"); + + b.Property("SupportsQueueing") + .HasColumnType("boolean"); + + b.Property("SupportsReservation") + .HasColumnType("boolean"); + + b.Property("Tags") + .HasColumnType("text"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Code") + .IsUnique(); + + b.HasIndex("TenantId", "MerchantId"); + + b.ToTable("stores", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Stores.Entities.StoreBusinessHour", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CapacityLimit") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DayOfWeek") + .HasColumnType("integer"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("EndTime") + .HasColumnType("interval"); + + b.Property("HourType") + .HasColumnType("integer"); + + b.Property("Notes") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("StartTime") + .HasColumnType("interval"); + + b.Property("StoreId") + .HasColumnType("uuid"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId", "DayOfWeek"); + + b.ToTable("store_business_hours", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Stores.Entities.StoreDeliveryZone", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("DeliveryFee") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("EstimatedMinutes") + .HasColumnType("integer"); + + b.Property("MinimumOrderAmount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("PolygonGeoJson") + .IsRequired() + .HasColumnType("text"); + + b.Property("StoreId") + .HasColumnType("uuid"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.Property("ZoneName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId", "ZoneName"); + + b.ToTable("store_delivery_zones", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Stores.Entities.StoreEmployeeShift", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("EndTime") + .HasColumnType("interval"); + + b.Property("Notes") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("RoleType") + .HasColumnType("integer"); + + b.Property("ShiftDate") + .HasColumnType("timestamp with time zone"); + + b.Property("StaffId") + .HasColumnType("uuid"); + + b.Property("StartTime") + .HasColumnType("interval"); + + b.Property("StoreId") + .HasColumnType("uuid"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId", "ShiftDate", "StaffId") + .IsUnique(); + + b.ToTable("store_employee_shifts", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Stores.Entities.StoreHoliday", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("IsClosed") + .HasColumnType("boolean"); + + b.Property("Reason") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("StoreId") + .HasColumnType("uuid"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId", "Date") + .IsUnique(); + + b.ToTable("store_holidays", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Stores.Entities.StoreTable", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AreaId") + .HasColumnType("uuid"); + + b.Property("Capacity") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("QrCodeUrl") + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("StoreId") + .HasColumnType("uuid"); + + b.Property("TableCode") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("Tags") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId", "TableCode") + .IsUnique(); + + b.ToTable("store_tables", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Stores.Entities.StoreTableArea", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("Description") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("StoreId") + .HasColumnType("uuid"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId", "Name") + .IsUnique(); + + b.ToTable("store_table_areas", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Tenants.Entities.Tenant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Address") + .HasColumnType("text"); + + b.Property("City") + .HasColumnType("text"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ContactEmail") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("ContactName") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ContactPhone") + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("Country") + .HasColumnType("text"); + + b.Property("CoverImageUrl") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("EffectiveFrom") + .HasColumnType("timestamp with time zone"); + + b.Property("EffectiveTo") + .HasColumnType("timestamp with time zone"); + + b.Property("Industry") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("LegalEntityName") + .HasColumnType("text"); + + b.Property("LogoUrl") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("PrimaryOwnerUserId") + .HasColumnType("uuid"); + + b.Property("Province") + .HasColumnType("text"); + + b.Property("Remarks") + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.Property("ShortName") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("SuspendedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("SuspensionReason") + .HasColumnType("text"); + + b.Property("Tags") + .HasColumnType("text"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.Property("Website") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("tenants", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Tenants.Entities.TenantBillingStatement", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AmountDue") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("AmountPaid") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("DueDate") + .HasColumnType("timestamp with time zone"); + + b.Property("LineItemsJson") + .HasColumnType("text"); + + b.Property("PeriodEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("PeriodStart") + .HasColumnType("timestamp with time zone"); + + b.Property("StatementNo") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StatementNo") + .IsUnique(); + + b.ToTable("tenant_billing_statements", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Tenants.Entities.TenantNotification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Channel") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("Message") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("character varying(1024)"); + + b.Property("MetadataJson") + .HasColumnType("text"); + + b.Property("ReadAt") + .HasColumnType("timestamp with time zone"); + + b.Property("SentAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Severity") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Channel", "SentAt"); + + b.ToTable("tenant_notifications", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Tenants.Entities.TenantPackage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("Description") + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.Property("FeaturePoliciesJson") + .HasColumnType("text"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("MaxAccountCount") + .HasColumnType("integer"); + + b.Property("MaxDeliveryOrders") + .HasColumnType("integer"); + + b.Property("MaxSmsCredits") + .HasColumnType("integer"); + + b.Property("MaxStorageGb") + .HasColumnType("integer"); + + b.Property("MaxStoreCount") + .HasColumnType("integer"); + + b.Property("MonthlyPrice") + .HasColumnType("numeric"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("PackageType") + .HasColumnType("integer"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.Property("YearlyPrice") + .HasColumnType("numeric"); + + b.HasKey("Id"); + + b.ToTable("tenant_packages", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Tenants.Entities.TenantQuotaUsage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("LastResetAt") + .HasColumnType("timestamp with time zone"); + + b.Property("LimitValue") + .HasColumnType("numeric"); + + b.Property("QuotaType") + .HasColumnType("integer"); + + b.Property("ResetCycle") + .HasColumnType("text"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.Property("UsedValue") + .HasColumnType("numeric"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "QuotaType") + .IsUnique(); + + b.ToTable("tenant_quota_usages", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Tenants.Entities.TenantSubscription", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AutoRenew") + .HasColumnType("boolean"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("EffectiveFrom") + .HasColumnType("timestamp with time zone"); + + b.Property("EffectiveTo") + .HasColumnType("timestamp with time zone"); + + b.Property("NextBillingDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Notes") + .HasColumnType("text"); + + b.Property("ScheduledPackageId") + .HasColumnType("uuid"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("TenantPackageId") + .HasColumnType("uuid"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "TenantPackageId"); + + b.ToTable("tenant_subscriptions", (string)null); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Orders.Entities.OrderItem", b => + { + b.HasOne("TakeoutSaaS.Domain.Orders.Entities.Order", null) + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Infrastructure/TakeoutSaaS.Infrastructure/App/Migrations/20251201055852_ExpandDomainSchema.cs b/src/Infrastructure/TakeoutSaaS.Infrastructure/App/Migrations/20251201055852_ExpandDomainSchema.cs new file mode 100644 index 0000000..fc4cb04 --- /dev/null +++ b/src/Infrastructure/TakeoutSaaS.Infrastructure/App/Migrations/20251201055852_ExpandDomainSchema.cs @@ -0,0 +1,2206 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace TakeoutSaaS.Infrastructure.App.Migrations +{ + /// + public partial class ExpandDomainSchema : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_stores_merchants_MerchantId", + table: "stores"); + + migrationBuilder.DropIndex( + name: "IX_stores_MerchantId", + table: "stores"); + + migrationBuilder.RenameColumn( + name: "ReservationEnabled", + table: "stores", + newName: "SupportsReservation"); + + migrationBuilder.RenameColumn( + name: "QueueEnabled", + table: "stores", + newName: "SupportsQueueing"); + + migrationBuilder.RenameColumn( + name: "OnboardedAt", + table: "merchants", + newName: "LastReviewedAt"); + + migrationBuilder.AddColumn( + name: "Address", + table: "tenants", + type: "text", + nullable: true); + + migrationBuilder.AddColumn( + name: "City", + table: "tenants", + type: "text", + nullable: true); + + migrationBuilder.AddColumn( + name: "Country", + table: "tenants", + type: "text", + nullable: true); + + migrationBuilder.AddColumn( + name: "CoverImageUrl", + table: "tenants", + type: "text", + nullable: true); + + migrationBuilder.AddColumn( + name: "LegalEntityName", + table: "tenants", + type: "text", + nullable: true); + + migrationBuilder.AddColumn( + name: "PrimaryOwnerUserId", + table: "tenants", + type: "uuid", + nullable: true); + + migrationBuilder.AddColumn( + name: "Province", + table: "tenants", + type: "text", + nullable: true); + + migrationBuilder.AddColumn( + name: "SuspendedAt", + table: "tenants", + type: "timestamp with time zone", + nullable: true); + + migrationBuilder.AddColumn( + name: "SuspensionReason", + table: "tenants", + type: "text", + nullable: true); + + migrationBuilder.AddColumn( + name: "Tags", + table: "tenants", + type: "text", + nullable: true); + + migrationBuilder.AddColumn( + name: "Website", + table: "tenants", + type: "text", + nullable: true); + + migrationBuilder.AddColumn( + name: "Country", + table: "stores", + type: "text", + nullable: true); + + migrationBuilder.AddColumn( + name: "CoverImageUrl", + table: "stores", + type: "text", + nullable: true); + + migrationBuilder.AddColumn( + name: "Description", + table: "stores", + type: "text", + nullable: true); + + migrationBuilder.AddColumn( + name: "Tags", + table: "stores", + type: "text", + nullable: true); + + migrationBuilder.AddColumn( + name: "BusinessLicenseImageUrl", + table: "merchants", + type: "text", + nullable: true); + + migrationBuilder.AddColumn( + name: "Category", + table: "merchants", + type: "text", + nullable: true); + + migrationBuilder.AddColumn( + name: "JoinedAt", + table: "merchants", + type: "timestamp with time zone", + nullable: true); + + migrationBuilder.AddColumn( + name: "Latitude", + table: "merchants", + type: "double precision", + nullable: true); + + migrationBuilder.AddColumn( + name: "LogoUrl", + table: "merchants", + type: "text", + nullable: true); + + migrationBuilder.AddColumn( + name: "Longitude", + table: "merchants", + type: "double precision", + nullable: true); + + migrationBuilder.AddColumn( + name: "ServicePhone", + table: "merchants", + type: "text", + nullable: true); + + migrationBuilder.AddColumn( + name: "SupportEmail", + table: "merchants", + type: "text", + nullable: true); + + migrationBuilder.AddColumn( + name: "TaxNumber", + table: "merchants", + type: "text", + nullable: true); + + migrationBuilder.CreateTable( + name: "affiliate_orders", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + AffiliatePartnerId = table.Column(type: "uuid", nullable: false), + OrderId = table.Column(type: "uuid", nullable: false), + BuyerUserId = table.Column(type: "uuid", nullable: false), + OrderAmount = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false), + EstimatedCommission = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false), + Status = table.Column(type: "integer", nullable: false), + SettledAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_affiliate_orders", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "affiliate_partners", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + UserId = table.Column(type: "uuid", nullable: true), + DisplayName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), + Phone = table.Column(type: "character varying(32)", maxLength: 32, nullable: true), + ChannelType = table.Column(type: "integer", nullable: false), + CommissionRate = table.Column(type: "numeric", nullable: false), + Status = table.Column(type: "integer", nullable: false), + Remarks = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_affiliate_partners", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "affiliate_payouts", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + AffiliatePartnerId = table.Column(type: "uuid", nullable: false), + Period = table.Column(type: "character varying(32)", maxLength: 32, nullable: false), + Amount = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false), + Status = table.Column(type: "integer", nullable: false), + PaidAt = table.Column(type: "timestamp with time zone", nullable: true), + Remarks = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_affiliate_payouts", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "cart_item_addons", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + CartItemId = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), + ExtraPrice = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false), + OptionId = table.Column(type: "uuid", nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_cart_item_addons", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "cart_items", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + ShoppingCartId = table.Column(type: "uuid", nullable: false), + ProductId = table.Column(type: "uuid", nullable: false), + ProductSkuId = table.Column(type: "uuid", nullable: true), + ProductName = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), + UnitPrice = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false), + Quantity = table.Column(type: "integer", nullable: false), + Remark = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + Status = table.Column(type: "integer", nullable: false), + AttributesJson = table.Column(type: "text", nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_cart_items", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "chat_messages", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + ChatSessionId = table.Column(type: "uuid", nullable: false), + SenderType = table.Column(type: "integer", nullable: false), + SenderUserId = table.Column(type: "uuid", nullable: true), + Content = table.Column(type: "character varying(1024)", maxLength: 1024, nullable: false), + ContentType = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), + IsRead = table.Column(type: "boolean", nullable: false), + ReadAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_chat_messages", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "chat_sessions", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + SessionCode = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), + CustomerUserId = table.Column(type: "uuid", nullable: false), + AgentUserId = table.Column(type: "uuid", nullable: true), + StoreId = table.Column(type: "uuid", nullable: true), + Status = table.Column(type: "integer", nullable: false), + IsBotActive = table.Column(type: "boolean", nullable: false), + StartedAt = table.Column(type: "timestamp with time zone", nullable: false), + EndedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_chat_sessions", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "checkin_campaigns", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), + Description = table.Column(type: "character varying(512)", maxLength: 512, nullable: true), + StartDate = table.Column(type: "timestamp with time zone", nullable: false), + EndDate = table.Column(type: "timestamp with time zone", nullable: false), + AllowMakeupCount = table.Column(type: "integer", nullable: false), + RewardsJson = table.Column(type: "text", nullable: false), + Status = table.Column(type: "integer", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_checkin_campaigns", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "checkin_records", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + CheckInCampaignId = table.Column(type: "uuid", nullable: false), + UserId = table.Column(type: "uuid", nullable: false), + CheckInDate = table.Column(type: "timestamp with time zone", nullable: false), + IsMakeup = table.Column(type: "boolean", nullable: false), + RewardJson = table.Column(type: "text", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_checkin_records", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "checkout_sessions", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + UserId = table.Column(type: "uuid", nullable: false), + StoreId = table.Column(type: "uuid", nullable: false), + SessionToken = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), + Status = table.Column(type: "integer", nullable: false), + ValidationResultJson = table.Column(type: "text", nullable: false), + ExpiresAt = table.Column(type: "timestamp with time zone", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_checkout_sessions", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "community_comments", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + PostId = table.Column(type: "uuid", nullable: false), + AuthorUserId = table.Column(type: "uuid", nullable: false), + Content = table.Column(type: "character varying(512)", maxLength: 512, nullable: false), + ParentId = table.Column(type: "uuid", nullable: true), + IsDeleted = table.Column(type: "boolean", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_community_comments", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "community_posts", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + AuthorUserId = table.Column(type: "uuid", nullable: false), + Title = table.Column(type: "character varying(128)", maxLength: 128, nullable: true), + Content = table.Column(type: "text", nullable: false), + MediaJson = table.Column(type: "text", nullable: true), + Status = table.Column(type: "integer", nullable: false), + LikeCount = table.Column(type: "integer", nullable: false), + CommentCount = table.Column(type: "integer", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_community_posts", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "community_reactions", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + PostId = table.Column(type: "uuid", nullable: false), + UserId = table.Column(type: "uuid", nullable: false), + ReactionType = table.Column(type: "integer", nullable: false), + ReactedAt = table.Column(type: "timestamp with time zone", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_community_reactions", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "coupon_templates", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), + CouponType = table.Column(type: "integer", nullable: false), + Value = table.Column(type: "numeric", nullable: false), + DiscountCap = table.Column(type: "numeric", nullable: true), + MinimumSpend = table.Column(type: "numeric", nullable: true), + ValidFrom = table.Column(type: "timestamp with time zone", nullable: true), + ValidTo = table.Column(type: "timestamp with time zone", nullable: true), + RelativeValidDays = table.Column(type: "integer", nullable: true), + TotalQuantity = table.Column(type: "integer", nullable: true), + ClaimedQuantity = table.Column(type: "integer", nullable: false), + StoreScopeJson = table.Column(type: "text", nullable: true), + ProductScopeJson = table.Column(type: "text", nullable: true), + ChannelsJson = table.Column(type: "text", nullable: true), + AllowStack = table.Column(type: "boolean", nullable: false), + Status = table.Column(type: "integer", nullable: false), + Description = table.Column(type: "character varying(512)", maxLength: 512, nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_coupon_templates", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "coupons", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + CouponTemplateId = table.Column(type: "uuid", nullable: false), + Code = table.Column(type: "character varying(32)", maxLength: 32, nullable: false), + UserId = table.Column(type: "uuid", nullable: false), + OrderId = table.Column(type: "uuid", nullable: true), + Status = table.Column(type: "integer", nullable: false), + IssuedAt = table.Column(type: "timestamp with time zone", nullable: false), + UsedAt = table.Column(type: "timestamp with time zone", nullable: true), + ExpireAt = table.Column(type: "timestamp with time zone", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_coupons", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "delivery_events", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + DeliveryOrderId = table.Column(type: "uuid", nullable: false), + EventType = table.Column(type: "integer", nullable: false), + Message = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), + Payload = table.Column(type: "text", nullable: true), + OccurredAt = table.Column(type: "timestamp with time zone", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_delivery_events", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "group_orders", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + StoreId = table.Column(type: "uuid", nullable: false), + ProductId = table.Column(type: "uuid", nullable: false), + GroupOrderNo = table.Column(type: "character varying(32)", maxLength: 32, nullable: false), + LeaderUserId = table.Column(type: "uuid", nullable: false), + TargetCount = table.Column(type: "integer", nullable: false), + CurrentCount = table.Column(type: "integer", nullable: false), + GroupPrice = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false), + StartAt = table.Column(type: "timestamp with time zone", nullable: false), + EndAt = table.Column(type: "timestamp with time zone", nullable: false), + Status = table.Column(type: "integer", nullable: false), + SucceededAt = table.Column(type: "timestamp with time zone", nullable: true), + CancelledAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_group_orders", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "group_participants", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + GroupOrderId = table.Column(type: "uuid", nullable: false), + OrderId = table.Column(type: "uuid", nullable: false), + UserId = table.Column(type: "uuid", nullable: false), + Status = table.Column(type: "integer", nullable: false), + JoinedAt = table.Column(type: "timestamp with time zone", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_group_participants", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "inventory_adjustments", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + InventoryItemId = table.Column(type: "uuid", nullable: false), + AdjustmentType = table.Column(type: "integer", nullable: false), + Quantity = table.Column(type: "integer", nullable: false), + Reason = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + OperatorId = table.Column(type: "uuid", nullable: true), + OccurredAt = table.Column(type: "timestamp with time zone", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_inventory_adjustments", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "inventory_batches", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + StoreId = table.Column(type: "uuid", nullable: false), + ProductSkuId = table.Column(type: "uuid", nullable: false), + BatchNumber = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), + ProductionDate = table.Column(type: "timestamp with time zone", nullable: true), + ExpireDate = table.Column(type: "timestamp with time zone", nullable: true), + Quantity = table.Column(type: "integer", nullable: false), + RemainingQuantity = table.Column(type: "integer", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_inventory_batches", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "inventory_items", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + StoreId = table.Column(type: "uuid", nullable: false), + ProductSkuId = table.Column(type: "uuid", nullable: false), + BatchNumber = table.Column(type: "character varying(64)", maxLength: 64, nullable: true), + QuantityOnHand = table.Column(type: "integer", nullable: false), + QuantityReserved = table.Column(type: "integer", nullable: false), + SafetyStock = table.Column(type: "integer", nullable: true), + Location = table.Column(type: "character varying(64)", maxLength: 64, nullable: true), + ExpireDate = table.Column(type: "timestamp with time zone", nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_inventory_items", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "map_locations", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + StoreId = table.Column(type: "uuid", nullable: true), + Name = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), + Address = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), + Longitude = table.Column(type: "double precision", nullable: false), + Latitude = table.Column(type: "double precision", nullable: false), + Landmark = table.Column(type: "character varying(128)", maxLength: 128, nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_map_locations", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "member_growth_logs", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + MemberId = table.Column(type: "uuid", nullable: false), + ChangeValue = table.Column(type: "integer", nullable: false), + CurrentValue = table.Column(type: "integer", nullable: false), + Notes = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + OccurredAt = table.Column(type: "timestamp with time zone", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_member_growth_logs", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "member_point_ledgers", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + MemberId = table.Column(type: "uuid", nullable: false), + ChangeAmount = table.Column(type: "integer", nullable: false), + BalanceAfterChange = table.Column(type: "integer", nullable: false), + Reason = table.Column(type: "integer", nullable: false), + SourceId = table.Column(type: "uuid", nullable: true), + OccurredAt = table.Column(type: "timestamp with time zone", nullable: false), + ExpireAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_member_point_ledgers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "member_profiles", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + UserId = table.Column(type: "uuid", nullable: false), + Mobile = table.Column(type: "character varying(32)", maxLength: 32, nullable: false), + Nickname = table.Column(type: "character varying(64)", maxLength: 64, nullable: true), + AvatarUrl = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + MemberTierId = table.Column(type: "uuid", nullable: true), + Status = table.Column(type: "integer", nullable: false), + PointsBalance = table.Column(type: "integer", nullable: false), + GrowthValue = table.Column(type: "integer", nullable: false), + BirthDate = table.Column(type: "timestamp with time zone", nullable: true), + JoinedAt = table.Column(type: "timestamp with time zone", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_member_profiles", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "member_tiers", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), + RequiredGrowth = table.Column(type: "integer", nullable: false), + BenefitsJson = table.Column(type: "text", nullable: false), + SortOrder = table.Column(type: "integer", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_member_tiers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "merchant_contracts", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + MerchantId = table.Column(type: "uuid", nullable: false), + ContractNumber = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), + Status = table.Column(type: "integer", nullable: false), + StartDate = table.Column(type: "timestamp with time zone", nullable: false), + EndDate = table.Column(type: "timestamp with time zone", nullable: false), + FileUrl = table.Column(type: "character varying(512)", maxLength: 512, nullable: false), + SignedAt = table.Column(type: "timestamp with time zone", nullable: true), + TerminatedAt = table.Column(type: "timestamp with time zone", nullable: true), + TerminationReason = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_merchant_contracts", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "merchant_documents", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + MerchantId = table.Column(type: "uuid", nullable: false), + DocumentType = table.Column(type: "integer", nullable: false), + Status = table.Column(type: "integer", nullable: false), + FileUrl = table.Column(type: "character varying(512)", maxLength: 512, nullable: false), + DocumentNumber = table.Column(type: "character varying(64)", maxLength: 64, nullable: true), + IssuedAt = table.Column(type: "timestamp with time zone", nullable: true), + ExpiresAt = table.Column(type: "timestamp with time zone", nullable: true), + Remarks = table.Column(type: "text", nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_merchant_documents", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "merchant_staff", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + MerchantId = table.Column(type: "uuid", nullable: false), + StoreId = table.Column(type: "uuid", nullable: true), + Name = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), + Phone = table.Column(type: "character varying(32)", maxLength: 32, nullable: false), + Email = table.Column(type: "character varying(128)", maxLength: 128, nullable: true), + IdentityUserId = table.Column(type: "uuid", nullable: true), + RoleType = table.Column(type: "integer", nullable: false), + Status = table.Column(type: "integer", nullable: false), + PermissionsJson = table.Column(type: "text", nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_merchant_staff", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "metric_alert_rules", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + MetricDefinitionId = table.Column(type: "uuid", nullable: false), + ConditionJson = table.Column(type: "text", nullable: false), + Severity = table.Column(type: "integer", nullable: false), + NotificationChannels = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), + Enabled = table.Column(type: "boolean", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_metric_alert_rules", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "metric_definitions", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Code = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), + Name = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), + Description = table.Column(type: "character varying(512)", maxLength: 512, nullable: true), + DimensionsJson = table.Column(type: "text", nullable: true), + DefaultAggregation = table.Column(type: "character varying(32)", maxLength: 32, nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_metric_definitions", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "metric_snapshots", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + MetricDefinitionId = table.Column(type: "uuid", nullable: false), + DimensionKey = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), + WindowStart = table.Column(type: "timestamp with time zone", nullable: false), + WindowEnd = table.Column(type: "timestamp with time zone", nullable: false), + Value = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_metric_snapshots", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "navigation_requests", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + UserId = table.Column(type: "uuid", nullable: false), + StoreId = table.Column(type: "uuid", nullable: false), + Channel = table.Column(type: "integer", nullable: false), + TargetApp = table.Column(type: "integer", nullable: false), + RequestedAt = table.Column(type: "timestamp with time zone", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_navigation_requests", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "order_status_histories", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + OrderId = table.Column(type: "uuid", nullable: false), + Status = table.Column(type: "integer", nullable: false), + OperatorId = table.Column(type: "uuid", nullable: true), + Notes = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + OccurredAt = table.Column(type: "timestamp with time zone", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_order_status_histories", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "payment_refund_records", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + PaymentRecordId = table.Column(type: "uuid", nullable: false), + OrderId = table.Column(type: "uuid", nullable: false), + Amount = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false), + ChannelRefundId = table.Column(type: "character varying(64)", maxLength: 64, nullable: true), + Status = table.Column(type: "integer", nullable: false), + RequestedAt = table.Column(type: "timestamp with time zone", nullable: false), + CompletedAt = table.Column(type: "timestamp with time zone", nullable: true), + Payload = table.Column(type: "text", nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_payment_refund_records", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "product_addon_groups", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + ProductId = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), + SelectionType = table.Column(type: "integer", nullable: false), + MinSelect = table.Column(type: "integer", nullable: true), + MaxSelect = table.Column(type: "integer", nullable: true), + IsRequired = table.Column(type: "boolean", nullable: false), + SortOrder = table.Column(type: "integer", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_product_addon_groups", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "product_addon_options", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + AddonGroupId = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), + ExtraPrice = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: true), + IsDefault = table.Column(type: "boolean", nullable: false), + SortOrder = table.Column(type: "integer", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_product_addon_options", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "product_attribute_groups", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + StoreId = table.Column(type: "uuid", nullable: true), + Name = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), + SelectionType = table.Column(type: "integer", nullable: false), + IsRequired = table.Column(type: "boolean", nullable: false), + SortOrder = table.Column(type: "integer", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_product_attribute_groups", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "product_attribute_options", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + AttributeGroupId = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), + ExtraPrice = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: true), + SortOrder = table.Column(type: "integer", nullable: false), + IsDefault = table.Column(type: "boolean", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_product_attribute_options", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "product_media_assets", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + ProductId = table.Column(type: "uuid", nullable: false), + MediaType = table.Column(type: "integer", nullable: false), + Url = table.Column(type: "character varying(512)", maxLength: 512, nullable: false), + Caption = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + SortOrder = table.Column(type: "integer", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_product_media_assets", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "product_pricing_rules", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + ProductId = table.Column(type: "uuid", nullable: false), + RuleType = table.Column(type: "integer", nullable: false), + ConditionsJson = table.Column(type: "text", nullable: false), + Price = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false), + StartTime = table.Column(type: "timestamp with time zone", nullable: true), + EndTime = table.Column(type: "timestamp with time zone", nullable: true), + WeekdaysJson = table.Column(type: "text", nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_product_pricing_rules", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "product_skus", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + ProductId = table.Column(type: "uuid", nullable: false), + SkuCode = table.Column(type: "character varying(32)", maxLength: 32, nullable: false), + Barcode = table.Column(type: "character varying(64)", maxLength: 64, nullable: true), + Price = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false), + OriginalPrice = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: true), + StockQuantity = table.Column(type: "integer", nullable: true), + Weight = table.Column(type: "numeric(10,3)", precision: 10, scale: 3, nullable: true), + AttributesJson = table.Column(type: "text", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_product_skus", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "promotion_campaigns", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), + PromotionType = table.Column(type: "integer", nullable: false), + Status = table.Column(type: "integer", nullable: false), + StartAt = table.Column(type: "timestamp with time zone", nullable: false), + EndAt = table.Column(type: "timestamp with time zone", nullable: false), + Budget = table.Column(type: "numeric", nullable: true), + RulesJson = table.Column(type: "text", nullable: false), + AudienceDescription = table.Column(type: "character varying(512)", maxLength: 512, nullable: true), + BannerUrl = table.Column(type: "character varying(512)", maxLength: 512, nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_promotion_campaigns", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "refund_requests", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + OrderId = table.Column(type: "uuid", nullable: false), + RefundNo = table.Column(type: "character varying(32)", maxLength: 32, nullable: false), + Amount = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false), + Reason = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), + Status = table.Column(type: "integer", nullable: false), + RequestedAt = table.Column(type: "timestamp with time zone", nullable: false), + ProcessedAt = table.Column(type: "timestamp with time zone", nullable: true), + ReviewNotes = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_refund_requests", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "shopping_carts", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + UserId = table.Column(type: "uuid", nullable: false), + StoreId = table.Column(type: "uuid", nullable: false), + Status = table.Column(type: "integer", nullable: false), + TableContext = table.Column(type: "character varying(64)", maxLength: 64, nullable: true), + DeliveryPreference = table.Column(type: "character varying(32)", maxLength: 32, nullable: true), + LastModifiedAt = table.Column(type: "timestamp with time zone", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_shopping_carts", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "store_business_hours", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + StoreId = table.Column(type: "uuid", nullable: false), + DayOfWeek = table.Column(type: "integer", nullable: false), + HourType = table.Column(type: "integer", nullable: false), + StartTime = table.Column(type: "interval", nullable: false), + EndTime = table.Column(type: "interval", nullable: false), + CapacityLimit = table.Column(type: "integer", nullable: true), + Notes = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_store_business_hours", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "store_delivery_zones", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + StoreId = table.Column(type: "uuid", nullable: false), + ZoneName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), + PolygonGeoJson = table.Column(type: "text", nullable: false), + MinimumOrderAmount = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: true), + DeliveryFee = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: true), + EstimatedMinutes = table.Column(type: "integer", nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_store_delivery_zones", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "store_employee_shifts", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + StoreId = table.Column(type: "uuid", nullable: false), + StaffId = table.Column(type: "uuid", nullable: false), + ShiftDate = table.Column(type: "timestamp with time zone", nullable: false), + StartTime = table.Column(type: "interval", nullable: false), + EndTime = table.Column(type: "interval", nullable: false), + RoleType = table.Column(type: "integer", nullable: false), + Notes = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_store_employee_shifts", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "store_holidays", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + StoreId = table.Column(type: "uuid", nullable: false), + Date = table.Column(type: "timestamp with time zone", nullable: false), + IsClosed = table.Column(type: "boolean", nullable: false), + Reason = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_store_holidays", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "store_table_areas", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + StoreId = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), + Description = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_store_table_areas", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "store_tables", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + StoreId = table.Column(type: "uuid", nullable: false), + AreaId = table.Column(type: "uuid", nullable: true), + TableCode = table.Column(type: "character varying(32)", maxLength: 32, nullable: false), + Capacity = table.Column(type: "integer", nullable: false), + Tags = table.Column(type: "character varying(128)", maxLength: 128, nullable: true), + Status = table.Column(type: "integer", nullable: false), + QrCodeUrl = table.Column(type: "character varying(512)", maxLength: 512, nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_store_tables", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "support_tickets", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + TicketNo = table.Column(type: "character varying(32)", maxLength: 32, nullable: false), + CustomerUserId = table.Column(type: "uuid", nullable: false), + OrderId = table.Column(type: "uuid", nullable: true), + Subject = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), + Description = table.Column(type: "text", nullable: false), + Priority = table.Column(type: "integer", nullable: false), + Status = table.Column(type: "integer", nullable: false), + AssignedAgentId = table.Column(type: "uuid", nullable: true), + ClosedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_support_tickets", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "tenant_billing_statements", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + StatementNo = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), + PeriodStart = table.Column(type: "timestamp with time zone", nullable: false), + PeriodEnd = table.Column(type: "timestamp with time zone", nullable: false), + AmountDue = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false), + AmountPaid = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false), + Status = table.Column(type: "integer", nullable: false), + DueDate = table.Column(type: "timestamp with time zone", nullable: false), + LineItemsJson = table.Column(type: "text", nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_tenant_billing_statements", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "tenant_notifications", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Title = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), + Message = table.Column(type: "character varying(1024)", maxLength: 1024, nullable: false), + Channel = table.Column(type: "integer", nullable: false), + Severity = table.Column(type: "integer", nullable: false), + SentAt = table.Column(type: "timestamp with time zone", nullable: false), + ReadAt = table.Column(type: "timestamp with time zone", nullable: true), + MetadataJson = table.Column(type: "text", nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_tenant_notifications", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "tenant_packages", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), + Description = table.Column(type: "character varying(512)", maxLength: 512, nullable: true), + PackageType = table.Column(type: "integer", nullable: false), + MonthlyPrice = table.Column(type: "numeric", nullable: true), + YearlyPrice = table.Column(type: "numeric", nullable: true), + MaxStoreCount = table.Column(type: "integer", nullable: true), + MaxAccountCount = table.Column(type: "integer", nullable: true), + MaxStorageGb = table.Column(type: "integer", nullable: true), + MaxSmsCredits = table.Column(type: "integer", nullable: true), + MaxDeliveryOrders = table.Column(type: "integer", nullable: true), + FeaturePoliciesJson = table.Column(type: "text", nullable: true), + IsActive = table.Column(type: "boolean", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_tenant_packages", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "tenant_quota_usages", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + QuotaType = table.Column(type: "integer", nullable: false), + LimitValue = table.Column(type: "numeric", nullable: false), + UsedValue = table.Column(type: "numeric", nullable: false), + ResetCycle = table.Column(type: "text", nullable: true), + LastResetAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_tenant_quota_usages", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "tenant_subscriptions", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + TenantPackageId = table.Column(type: "uuid", nullable: false), + EffectiveFrom = table.Column(type: "timestamp with time zone", nullable: false), + EffectiveTo = table.Column(type: "timestamp with time zone", nullable: false), + NextBillingDate = table.Column(type: "timestamp with time zone", nullable: true), + Status = table.Column(type: "integer", nullable: false), + AutoRenew = table.Column(type: "boolean", nullable: false), + ScheduledPackageId = table.Column(type: "uuid", nullable: true), + Notes = table.Column(type: "text", nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_tenant_subscriptions", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "ticket_comments", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + SupportTicketId = table.Column(type: "uuid", nullable: false), + AuthorUserId = table.Column(type: "uuid", nullable: true), + Content = table.Column(type: "character varying(1024)", maxLength: 1024, nullable: false), + IsInternal = table.Column(type: "boolean", nullable: false), + AttachmentsJson = table.Column(type: "text", nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "uuid", nullable: true), + UpdatedBy = table.Column(type: "uuid", nullable: true), + DeletedBy = table.Column(type: "uuid", nullable: true), + TenantId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ticket_comments", x => x.Id); + }); + + migrationBuilder.CreateIndex( + name: "IX_affiliate_orders_TenantId_AffiliatePartnerId_OrderId", + table: "affiliate_orders", + columns: new[] { "TenantId", "AffiliatePartnerId", "OrderId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_affiliate_partners_TenantId_DisplayName", + table: "affiliate_partners", + columns: new[] { "TenantId", "DisplayName" }); + + migrationBuilder.CreateIndex( + name: "IX_affiliate_payouts_TenantId_AffiliatePartnerId_Period", + table: "affiliate_payouts", + columns: new[] { "TenantId", "AffiliatePartnerId", "Period" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_cart_items_TenantId_ShoppingCartId", + table: "cart_items", + columns: new[] { "TenantId", "ShoppingCartId" }); + + migrationBuilder.CreateIndex( + name: "IX_chat_messages_TenantId_ChatSessionId_CreatedAt", + table: "chat_messages", + columns: new[] { "TenantId", "ChatSessionId", "CreatedAt" }); + + migrationBuilder.CreateIndex( + name: "IX_chat_sessions_TenantId_SessionCode", + table: "chat_sessions", + columns: new[] { "TenantId", "SessionCode" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_checkin_campaigns_TenantId_Name", + table: "checkin_campaigns", + columns: new[] { "TenantId", "Name" }); + + migrationBuilder.CreateIndex( + name: "IX_checkin_records_TenantId_CheckInCampaignId_UserId_CheckInDa~", + table: "checkin_records", + columns: new[] { "TenantId", "CheckInCampaignId", "UserId", "CheckInDate" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_checkout_sessions_TenantId_SessionToken", + table: "checkout_sessions", + columns: new[] { "TenantId", "SessionToken" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_community_comments_TenantId_PostId_CreatedAt", + table: "community_comments", + columns: new[] { "TenantId", "PostId", "CreatedAt" }); + + migrationBuilder.CreateIndex( + name: "IX_community_posts_TenantId_AuthorUserId_CreatedAt", + table: "community_posts", + columns: new[] { "TenantId", "AuthorUserId", "CreatedAt" }); + + migrationBuilder.CreateIndex( + name: "IX_community_reactions_TenantId_PostId_UserId", + table: "community_reactions", + columns: new[] { "TenantId", "PostId", "UserId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_coupons_TenantId_Code", + table: "coupons", + columns: new[] { "TenantId", "Code" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_delivery_events_TenantId_DeliveryOrderId_EventType", + table: "delivery_events", + columns: new[] { "TenantId", "DeliveryOrderId", "EventType" }); + + migrationBuilder.CreateIndex( + name: "IX_group_orders_TenantId_GroupOrderNo", + table: "group_orders", + columns: new[] { "TenantId", "GroupOrderNo" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_group_participants_TenantId_GroupOrderId_UserId", + table: "group_participants", + columns: new[] { "TenantId", "GroupOrderId", "UserId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_inventory_adjustments_TenantId_InventoryItemId_OccurredAt", + table: "inventory_adjustments", + columns: new[] { "TenantId", "InventoryItemId", "OccurredAt" }); + + migrationBuilder.CreateIndex( + name: "IX_inventory_batches_TenantId_StoreId_ProductSkuId_BatchNumber", + table: "inventory_batches", + columns: new[] { "TenantId", "StoreId", "ProductSkuId", "BatchNumber" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_inventory_items_TenantId_StoreId_ProductSkuId_BatchNumber", + table: "inventory_items", + columns: new[] { "TenantId", "StoreId", "ProductSkuId", "BatchNumber" }); + + migrationBuilder.CreateIndex( + name: "IX_map_locations_TenantId_StoreId", + table: "map_locations", + columns: new[] { "TenantId", "StoreId" }); + + migrationBuilder.CreateIndex( + name: "IX_member_growth_logs_TenantId_MemberId_OccurredAt", + table: "member_growth_logs", + columns: new[] { "TenantId", "MemberId", "OccurredAt" }); + + migrationBuilder.CreateIndex( + name: "IX_member_point_ledgers_TenantId_MemberId_OccurredAt", + table: "member_point_ledgers", + columns: new[] { "TenantId", "MemberId", "OccurredAt" }); + + migrationBuilder.CreateIndex( + name: "IX_member_profiles_TenantId_Mobile", + table: "member_profiles", + columns: new[] { "TenantId", "Mobile" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_member_tiers_TenantId_Name", + table: "member_tiers", + columns: new[] { "TenantId", "Name" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_merchant_contracts_TenantId_MerchantId_ContractNumber", + table: "merchant_contracts", + columns: new[] { "TenantId", "MerchantId", "ContractNumber" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_merchant_documents_TenantId_MerchantId_DocumentType", + table: "merchant_documents", + columns: new[] { "TenantId", "MerchantId", "DocumentType" }); + + migrationBuilder.CreateIndex( + name: "IX_merchant_staff_TenantId_MerchantId_Phone", + table: "merchant_staff", + columns: new[] { "TenantId", "MerchantId", "Phone" }); + + migrationBuilder.CreateIndex( + name: "IX_metric_alert_rules_TenantId_MetricDefinitionId_Severity", + table: "metric_alert_rules", + columns: new[] { "TenantId", "MetricDefinitionId", "Severity" }); + + migrationBuilder.CreateIndex( + name: "IX_metric_definitions_TenantId_Code", + table: "metric_definitions", + columns: new[] { "TenantId", "Code" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_metric_snapshots_TenantId_MetricDefinitionId_DimensionKey_W~", + table: "metric_snapshots", + columns: new[] { "TenantId", "MetricDefinitionId", "DimensionKey", "WindowStart", "WindowEnd" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_navigation_requests_TenantId_UserId_StoreId_RequestedAt", + table: "navigation_requests", + columns: new[] { "TenantId", "UserId", "StoreId", "RequestedAt" }); + + migrationBuilder.CreateIndex( + name: "IX_order_status_histories_TenantId_OrderId_OccurredAt", + table: "order_status_histories", + columns: new[] { "TenantId", "OrderId", "OccurredAt" }); + + migrationBuilder.CreateIndex( + name: "IX_payment_refund_records_TenantId_PaymentRecordId", + table: "payment_refund_records", + columns: new[] { "TenantId", "PaymentRecordId" }); + + migrationBuilder.CreateIndex( + name: "IX_product_addon_groups_TenantId_ProductId_Name", + table: "product_addon_groups", + columns: new[] { "TenantId", "ProductId", "Name" }); + + migrationBuilder.CreateIndex( + name: "IX_product_attribute_groups_TenantId_StoreId_Name", + table: "product_attribute_groups", + columns: new[] { "TenantId", "StoreId", "Name" }); + + migrationBuilder.CreateIndex( + name: "IX_product_attribute_options_TenantId_AttributeGroupId_Name", + table: "product_attribute_options", + columns: new[] { "TenantId", "AttributeGroupId", "Name" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_product_pricing_rules_TenantId_ProductId_RuleType", + table: "product_pricing_rules", + columns: new[] { "TenantId", "ProductId", "RuleType" }); + + migrationBuilder.CreateIndex( + name: "IX_product_skus_TenantId_SkuCode", + table: "product_skus", + columns: new[] { "TenantId", "SkuCode" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_refund_requests_TenantId_RefundNo", + table: "refund_requests", + columns: new[] { "TenantId", "RefundNo" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_shopping_carts_TenantId_UserId_StoreId", + table: "shopping_carts", + columns: new[] { "TenantId", "UserId", "StoreId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_store_business_hours_TenantId_StoreId_DayOfWeek", + table: "store_business_hours", + columns: new[] { "TenantId", "StoreId", "DayOfWeek" }); + + migrationBuilder.CreateIndex( + name: "IX_store_delivery_zones_TenantId_StoreId_ZoneName", + table: "store_delivery_zones", + columns: new[] { "TenantId", "StoreId", "ZoneName" }); + + migrationBuilder.CreateIndex( + name: "IX_store_employee_shifts_TenantId_StoreId_ShiftDate_StaffId", + table: "store_employee_shifts", + columns: new[] { "TenantId", "StoreId", "ShiftDate", "StaffId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_store_holidays_TenantId_StoreId_Date", + table: "store_holidays", + columns: new[] { "TenantId", "StoreId", "Date" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_store_table_areas_TenantId_StoreId_Name", + table: "store_table_areas", + columns: new[] { "TenantId", "StoreId", "Name" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_store_tables_TenantId_StoreId_TableCode", + table: "store_tables", + columns: new[] { "TenantId", "StoreId", "TableCode" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_support_tickets_TenantId_TicketNo", + table: "support_tickets", + columns: new[] { "TenantId", "TicketNo" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_tenant_billing_statements_TenantId_StatementNo", + table: "tenant_billing_statements", + columns: new[] { "TenantId", "StatementNo" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_tenant_notifications_TenantId_Channel_SentAt", + table: "tenant_notifications", + columns: new[] { "TenantId", "Channel", "SentAt" }); + + migrationBuilder.CreateIndex( + name: "IX_tenant_quota_usages_TenantId_QuotaType", + table: "tenant_quota_usages", + columns: new[] { "TenantId", "QuotaType" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_tenant_subscriptions_TenantId_TenantPackageId", + table: "tenant_subscriptions", + columns: new[] { "TenantId", "TenantPackageId" }); + + migrationBuilder.CreateIndex( + name: "IX_ticket_comments_TenantId_SupportTicketId", + table: "ticket_comments", + columns: new[] { "TenantId", "SupportTicketId" }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "affiliate_orders"); + + migrationBuilder.DropTable( + name: "affiliate_partners"); + + migrationBuilder.DropTable( + name: "affiliate_payouts"); + + migrationBuilder.DropTable( + name: "cart_item_addons"); + + migrationBuilder.DropTable( + name: "cart_items"); + + migrationBuilder.DropTable( + name: "chat_messages"); + + migrationBuilder.DropTable( + name: "chat_sessions"); + + migrationBuilder.DropTable( + name: "checkin_campaigns"); + + migrationBuilder.DropTable( + name: "checkin_records"); + + migrationBuilder.DropTable( + name: "checkout_sessions"); + + migrationBuilder.DropTable( + name: "community_comments"); + + migrationBuilder.DropTable( + name: "community_posts"); + + migrationBuilder.DropTable( + name: "community_reactions"); + + migrationBuilder.DropTable( + name: "coupon_templates"); + + migrationBuilder.DropTable( + name: "coupons"); + + migrationBuilder.DropTable( + name: "delivery_events"); + + migrationBuilder.DropTable( + name: "group_orders"); + + migrationBuilder.DropTable( + name: "group_participants"); + + migrationBuilder.DropTable( + name: "inventory_adjustments"); + + migrationBuilder.DropTable( + name: "inventory_batches"); + + migrationBuilder.DropTable( + name: "inventory_items"); + + migrationBuilder.DropTable( + name: "map_locations"); + + migrationBuilder.DropTable( + name: "member_growth_logs"); + + migrationBuilder.DropTable( + name: "member_point_ledgers"); + + migrationBuilder.DropTable( + name: "member_profiles"); + + migrationBuilder.DropTable( + name: "member_tiers"); + + migrationBuilder.DropTable( + name: "merchant_contracts"); + + migrationBuilder.DropTable( + name: "merchant_documents"); + + migrationBuilder.DropTable( + name: "merchant_staff"); + + migrationBuilder.DropTable( + name: "metric_alert_rules"); + + migrationBuilder.DropTable( + name: "metric_definitions"); + + migrationBuilder.DropTable( + name: "metric_snapshots"); + + migrationBuilder.DropTable( + name: "navigation_requests"); + + migrationBuilder.DropTable( + name: "order_status_histories"); + + migrationBuilder.DropTable( + name: "payment_refund_records"); + + migrationBuilder.DropTable( + name: "product_addon_groups"); + + migrationBuilder.DropTable( + name: "product_addon_options"); + + migrationBuilder.DropTable( + name: "product_attribute_groups"); + + migrationBuilder.DropTable( + name: "product_attribute_options"); + + migrationBuilder.DropTable( + name: "product_media_assets"); + + migrationBuilder.DropTable( + name: "product_pricing_rules"); + + migrationBuilder.DropTable( + name: "product_skus"); + + migrationBuilder.DropTable( + name: "promotion_campaigns"); + + migrationBuilder.DropTable( + name: "refund_requests"); + + migrationBuilder.DropTable( + name: "shopping_carts"); + + migrationBuilder.DropTable( + name: "store_business_hours"); + + migrationBuilder.DropTable( + name: "store_delivery_zones"); + + migrationBuilder.DropTable( + name: "store_employee_shifts"); + + migrationBuilder.DropTable( + name: "store_holidays"); + + migrationBuilder.DropTable( + name: "store_table_areas"); + + migrationBuilder.DropTable( + name: "store_tables"); + + migrationBuilder.DropTable( + name: "support_tickets"); + + migrationBuilder.DropTable( + name: "tenant_billing_statements"); + + migrationBuilder.DropTable( + name: "tenant_notifications"); + + migrationBuilder.DropTable( + name: "tenant_packages"); + + migrationBuilder.DropTable( + name: "tenant_quota_usages"); + + migrationBuilder.DropTable( + name: "tenant_subscriptions"); + + migrationBuilder.DropTable( + name: "ticket_comments"); + + migrationBuilder.DropColumn( + name: "Address", + table: "tenants"); + + migrationBuilder.DropColumn( + name: "City", + table: "tenants"); + + migrationBuilder.DropColumn( + name: "Country", + table: "tenants"); + + migrationBuilder.DropColumn( + name: "CoverImageUrl", + table: "tenants"); + + migrationBuilder.DropColumn( + name: "LegalEntityName", + table: "tenants"); + + migrationBuilder.DropColumn( + name: "PrimaryOwnerUserId", + table: "tenants"); + + migrationBuilder.DropColumn( + name: "Province", + table: "tenants"); + + migrationBuilder.DropColumn( + name: "SuspendedAt", + table: "tenants"); + + migrationBuilder.DropColumn( + name: "SuspensionReason", + table: "tenants"); + + migrationBuilder.DropColumn( + name: "Tags", + table: "tenants"); + + migrationBuilder.DropColumn( + name: "Website", + table: "tenants"); + + migrationBuilder.DropColumn( + name: "Country", + table: "stores"); + + migrationBuilder.DropColumn( + name: "CoverImageUrl", + table: "stores"); + + migrationBuilder.DropColumn( + name: "Description", + table: "stores"); + + migrationBuilder.DropColumn( + name: "Tags", + table: "stores"); + + migrationBuilder.DropColumn( + name: "BusinessLicenseImageUrl", + table: "merchants"); + + migrationBuilder.DropColumn( + name: "Category", + table: "merchants"); + + migrationBuilder.DropColumn( + name: "JoinedAt", + table: "merchants"); + + migrationBuilder.DropColumn( + name: "Latitude", + table: "merchants"); + + migrationBuilder.DropColumn( + name: "LogoUrl", + table: "merchants"); + + migrationBuilder.DropColumn( + name: "Longitude", + table: "merchants"); + + migrationBuilder.DropColumn( + name: "ServicePhone", + table: "merchants"); + + migrationBuilder.DropColumn( + name: "SupportEmail", + table: "merchants"); + + migrationBuilder.DropColumn( + name: "TaxNumber", + table: "merchants"); + + migrationBuilder.RenameColumn( + name: "SupportsReservation", + table: "stores", + newName: "ReservationEnabled"); + + migrationBuilder.RenameColumn( + name: "SupportsQueueing", + table: "stores", + newName: "QueueEnabled"); + + migrationBuilder.RenameColumn( + name: "LastReviewedAt", + table: "merchants", + newName: "OnboardedAt"); + + migrationBuilder.CreateIndex( + name: "IX_stores_MerchantId", + table: "stores", + column: "MerchantId"); + + migrationBuilder.AddForeignKey( + name: "FK_stores_merchants_MerchantId", + table: "stores", + column: "MerchantId", + principalTable: "merchants", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/src/Infrastructure/TakeoutSaaS.Infrastructure/App/Migrations/20251201094254_AddEntityComments.Designer.cs b/src/Infrastructure/TakeoutSaaS.Infrastructure/App/Migrations/20251201094254_AddEntityComments.Designer.cs new file mode 100644 index 0000000..2baf184 --- /dev/null +++ b/src/Infrastructure/TakeoutSaaS.Infrastructure/App/Migrations/20251201094254_AddEntityComments.Designer.cs @@ -0,0 +1,5641 @@ +// +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.App.Persistence; + +#nullable disable + +namespace TakeoutSaaS.Infrastructure.App.Migrations +{ + [DbContext(typeof(TakeoutAppDbContext))] + [Migration("20251201094254_AddEntityComments")] + partial class AddEntityComments + { + /// + 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.Analytics.Entities.MetricAlertRule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("ConditionJson") + .IsRequired() + .HasColumnType("text") + .HasComment("触发条件 JSON。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("Enabled") + .HasColumnType("boolean") + .HasComment("是否启用。"); + + b.Property("MetricDefinitionId") + .HasColumnType("uuid") + .HasComment("关联指标。"); + + b.Property("NotificationChannels") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("通知渠道。"); + + b.Property("Severity") + .HasColumnType("integer") + .HasComment("告警级别。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "MetricDefinitionId", "Severity"); + + b.ToTable("metric_alert_rules", null, t => + { + t.HasComment("指标告警规则。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Analytics.Entities.MetricDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("指标编码。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DefaultAggregation") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("默认聚合方式。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("Description") + .HasMaxLength(512) + .HasColumnType("character varying(512)") + .HasComment("说明。"); + + b.Property("DimensionsJson") + .HasColumnType("text") + .HasComment("维度描述 JSON。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("指标名称。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Code") + .IsUnique(); + + b.ToTable("metric_definitions", null, t => + { + t.HasComment("指标定义,描述可观测的数据点。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Analytics.Entities.MetricSnapshot", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("DimensionKey") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("维度键(JSON)。"); + + b.Property("MetricDefinitionId") + .HasColumnType("uuid") + .HasComment("指标定义 ID。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("Value") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)") + .HasComment("数值。"); + + b.Property("WindowEnd") + .HasColumnType("timestamp with time zone") + .HasComment("统计时间窗口结束。"); + + b.Property("WindowStart") + .HasColumnType("timestamp with time zone") + .HasComment("统计时间窗口开始。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "MetricDefinitionId", "DimensionKey", "WindowStart", "WindowEnd") + .IsUnique(); + + b.ToTable("metric_snapshots", null, t => + { + t.HasComment("指标快照,用于大盘展示。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Coupons.Entities.Coupon", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("券码或序列号。"); + + b.Property("CouponTemplateId") + .HasColumnType("uuid") + .HasComment("模板标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("ExpireAt") + .HasColumnType("timestamp with time zone") + .HasComment("到期时间。"); + + b.Property("IssuedAt") + .HasColumnType("timestamp with time zone") + .HasComment("发放时间。"); + + b.Property("OrderId") + .HasColumnType("uuid") + .HasComment("订单 ID(已使用时记录)。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("UsedAt") + .HasColumnType("timestamp with time zone") + .HasComment("使用时间。"); + + b.Property("UserId") + .HasColumnType("uuid") + .HasComment("归属用户。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Code") + .IsUnique(); + + b.ToTable("coupons", null, t => + { + t.HasComment("用户领取的券。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Coupons.Entities.CouponTemplate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AllowStack") + .HasColumnType("boolean") + .HasComment("是否允许叠加其他优惠。"); + + b.Property("ChannelsJson") + .HasColumnType("text") + .HasComment("发放渠道(JSON)。"); + + b.Property("ClaimedQuantity") + .HasColumnType("integer") + .HasComment("已领取数量。"); + + b.Property("CouponType") + .HasColumnType("integer") + .HasComment("券类型。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("Description") + .HasMaxLength(512) + .HasColumnType("character varying(512)") + .HasComment("备注。"); + + b.Property("DiscountCap") + .HasColumnType("numeric") + .HasComment("折扣上限(针对折扣券)。"); + + b.Property("MinimumSpend") + .HasColumnType("numeric") + .HasComment("最低消费门槛。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("模板名称。"); + + b.Property("ProductScopeJson") + .HasColumnType("text") + .HasComment("适用品类或商品范围(JSON)。"); + + b.Property("RelativeValidDays") + .HasColumnType("integer") + .HasComment("有效天数(相对发放时间)。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("状态。"); + + b.Property("StoreScopeJson") + .HasColumnType("text") + .HasComment("适用门店 ID 集合(JSON)。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("TotalQuantity") + .HasColumnType("integer") + .HasComment("总发放数量上限。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("ValidFrom") + .HasColumnType("timestamp with time zone") + .HasComment("可用开始时间。"); + + b.Property("ValidTo") + .HasColumnType("timestamp with time zone") + .HasComment("可用结束时间。"); + + b.Property("Value") + .HasColumnType("numeric") + .HasComment("面值或折扣额度。"); + + b.HasKey("Id"); + + b.ToTable("coupon_templates", null, t => + { + t.HasComment("优惠券模板。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Coupons.Entities.PromotionCampaign", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AudienceDescription") + .HasMaxLength(512) + .HasColumnType("character varying(512)") + .HasComment("目标人群描述。"); + + b.Property("BannerUrl") + .HasMaxLength(512) + .HasColumnType("character varying(512)") + .HasComment("营销素材(如 banner)。"); + + b.Property("Budget") + .HasColumnType("numeric") + .HasComment("预算金额。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("EndAt") + .HasColumnType("timestamp with time zone") + .HasComment("结束时间。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("活动名称。"); + + b.Property("PromotionType") + .HasColumnType("integer") + .HasComment("活动类型。"); + + b.Property("RulesJson") + .IsRequired() + .HasColumnType("text") + .HasComment("活动规则 JSON。"); + + b.Property("StartAt") + .HasColumnType("timestamp with time zone") + .HasComment("开始时间。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("活动状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.ToTable("promotion_campaigns", null, t => + { + t.HasComment("营销活动配置。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.CustomerService.Entities.ChatMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("ChatSessionId") + .HasColumnType("uuid") + .HasComment("会话标识。"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("character varying(1024)") + .HasComment("消息内容。"); + + b.Property("ContentType") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("消息类型(文字/图片/语音等)。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("IsRead") + .HasColumnType("boolean") + .HasComment("是否已读。"); + + b.Property("ReadAt") + .HasColumnType("timestamp with time zone") + .HasComment("读取时间。"); + + b.Property("SenderType") + .HasColumnType("integer") + .HasComment("发送方类型。"); + + b.Property("SenderUserId") + .HasColumnType("uuid") + .HasComment("发送方用户 ID。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "ChatSessionId", "CreatedAt"); + + b.ToTable("chat_messages", null, t => + { + t.HasComment("会话消息。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.CustomerService.Entities.ChatSession", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AgentUserId") + .HasColumnType("uuid") + .HasComment("当前客服员工 ID。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("CustomerUserId") + .HasColumnType("uuid") + .HasComment("顾客用户 ID。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("EndedAt") + .HasColumnType("timestamp with time zone") + .HasComment("结束时间。"); + + b.Property("IsBotActive") + .HasColumnType("boolean") + .HasComment("是否机器人接待中。"); + + b.Property("SessionCode") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("会话编号。"); + + b.Property("StartedAt") + .HasColumnType("timestamp with time zone") + .HasComment("开始时间。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("会话状态。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("所属门店(可空为平台)。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "SessionCode") + .IsUnique(); + + b.ToTable("chat_sessions", null, t => + { + t.HasComment("客服会话。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.CustomerService.Entities.SupportTicket", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AssignedAgentId") + .HasColumnType("uuid") + .HasComment("指派的客服。"); + + b.Property("ClosedAt") + .HasColumnType("timestamp with time zone") + .HasComment("关闭时间。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("CustomerUserId") + .HasColumnType("uuid") + .HasComment("客户用户 ID。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text") + .HasComment("工单详情。"); + + b.Property("OrderId") + .HasColumnType("uuid") + .HasComment("关联订单(如有)。"); + + b.Property("Priority") + .HasColumnType("integer") + .HasComment("优先级。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("状态。"); + + b.Property("Subject") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("工单主题。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("TicketNo") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("工单编号。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "TicketNo") + .IsUnique(); + + b.ToTable("support_tickets", null, t => + { + t.HasComment("客服工单。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.CustomerService.Entities.TicketComment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AttachmentsJson") + .HasColumnType("text") + .HasComment("附件 JSON。"); + + b.Property("AuthorUserId") + .HasColumnType("uuid") + .HasComment("评论人 ID。"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("character varying(1024)") + .HasComment("评论内容。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("IsInternal") + .HasColumnType("boolean") + .HasComment("是否内部备注。"); + + b.Property("SupportTicketId") + .HasColumnType("uuid") + .HasComment("工单标识。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "SupportTicketId"); + + b.ToTable("ticket_comments", null, t => + { + t.HasComment("工单评论/流转记录。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Deliveries.Entities.DeliveryEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("DeliveryOrderId") + .HasColumnType("uuid") + .HasComment("配送单标识。"); + + b.Property("EventType") + .HasColumnType("integer") + .HasComment("事件类型。"); + + b.Property("Message") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("事件描述。"); + + b.Property("OccurredAt") + .HasColumnType("timestamp with time zone") + .HasComment("发生时间。"); + + b.Property("Payload") + .HasColumnType("text") + .HasComment("原始数据 JSON。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "DeliveryOrderId", "EventType"); + + b.ToTable("delivery_events", null, t => + { + t.HasComment("配送状态事件流水。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Deliveries.Entities.DeliveryOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CourierName") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("骑手姓名。"); + + b.Property("CourierPhone") + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("骑手电话。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("DeliveredAt") + .HasColumnType("timestamp with time zone") + .HasComment("完成时间。"); + + b.Property("DeliveryFee") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("配送费。"); + + b.Property("DispatchedAt") + .HasColumnType("timestamp with time zone") + .HasComment("下发时间。"); + + b.Property("FailureReason") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("异常原因。"); + + b.Property("OrderId") + .HasColumnType("uuid"); + + b.Property("PickedUpAt") + .HasColumnType("timestamp with time zone") + .HasComment("取餐时间。"); + + b.Property("Provider") + .HasColumnType("integer") + .HasComment("配送服务商。"); + + b.Property("ProviderOrderId") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("第三方配送单号。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "OrderId") + .IsUnique(); + + b.ToTable("delivery_orders", null, t => + { + t.HasComment("配送单。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Distribution.Entities.AffiliateOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AffiliatePartnerId") + .HasColumnType("uuid") + .HasComment("推广人标识。"); + + b.Property("BuyerUserId") + .HasColumnType("uuid") + .HasComment("用户 ID。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("EstimatedCommission") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("预计佣金。"); + + b.Property("OrderAmount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("订单金额。"); + + b.Property("OrderId") + .HasColumnType("uuid") + .HasComment("关联订单。"); + + b.Property("SettledAt") + .HasColumnType("timestamp with time zone") + .HasComment("结算完成时间。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("当前状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "AffiliatePartnerId", "OrderId") + .IsUnique(); + + b.ToTable("affiliate_orders", null, t => + { + t.HasComment("分销订单记录。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Distribution.Entities.AffiliatePartner", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("ChannelType") + .HasColumnType("integer") + .HasComment("渠道类型。"); + + b.Property("CommissionRate") + .HasColumnType("numeric") + .HasComment("分成比例(0-1)。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("昵称或渠道名称。"); + + b.Property("Phone") + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("联系电话。"); + + b.Property("Remarks") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("审核备注。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("当前状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("UserId") + .HasColumnType("uuid") + .HasComment("用户 ID(如绑定平台账号)。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "DisplayName"); + + b.ToTable("affiliate_partners", null, t => + { + t.HasComment("分销/推广合作伙伴。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Distribution.Entities.AffiliatePayout", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AffiliatePartnerId") + .HasColumnType("uuid") + .HasComment("合作伙伴标识。"); + + b.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("结算金额。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("PaidAt") + .HasColumnType("timestamp with time zone") + .HasComment("打款时间。"); + + b.Property("Period") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("结算周期描述。"); + + b.Property("Remarks") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("备注。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "AffiliatePartnerId", "Period") + .IsUnique(); + + b.ToTable("affiliate_payouts", null, t => + { + t.HasComment("佣金结算记录。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Engagement.Entities.CheckInCampaign", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AllowMakeupCount") + .HasColumnType("integer") + .HasComment("支持补签次数。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("Description") + .HasMaxLength(512) + .HasColumnType("character varying(512)") + .HasComment("活动描述。"); + + b.Property("EndDate") + .HasColumnType("timestamp with time zone") + .HasComment("结束日期。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("活动名称。"); + + b.Property("RewardsJson") + .IsRequired() + .HasColumnType("text") + .HasComment("连签奖励 JSON。"); + + b.Property("StartDate") + .HasColumnType("timestamp with time zone") + .HasComment("开始日期。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Name"); + + b.ToTable("checkin_campaigns", null, t => + { + t.HasComment("签到活动配置。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Engagement.Entities.CheckInRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CheckInCampaignId") + .HasColumnType("uuid") + .HasComment("活动标识。"); + + b.Property("CheckInDate") + .HasColumnType("timestamp with time zone") + .HasComment("签到日期(本地)。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("IsMakeup") + .HasColumnType("boolean") + .HasComment("是否补签。"); + + b.Property("RewardJson") + .IsRequired() + .HasColumnType("text") + .HasComment("获得奖励 JSON。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("UserId") + .HasColumnType("uuid") + .HasComment("用户标识。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "CheckInCampaignId", "UserId", "CheckInDate") + .IsUnique(); + + b.ToTable("checkin_records", null, t => + { + t.HasComment("用户签到记录。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Engagement.Entities.CommunityComment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AuthorUserId") + .HasColumnType("uuid") + .HasComment("评论人。"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("character varying(512)") + .HasComment("评论内容。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("IsDeleted") + .HasColumnType("boolean") + .HasComment("状态。"); + + b.Property("ParentId") + .HasColumnType("uuid") + .HasComment("父级评论 ID。"); + + b.Property("PostId") + .HasColumnType("uuid") + .HasComment("动态标识。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "PostId", "CreatedAt"); + + b.ToTable("community_comments", null, t => + { + t.HasComment("社区评论。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Engagement.Entities.CommunityPost", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AuthorUserId") + .HasColumnType("uuid") + .HasComment("作者用户 ID。"); + + b.Property("CommentCount") + .HasColumnType("integer") + .HasComment("评论数。"); + + b.Property("Content") + .IsRequired() + .HasColumnType("text") + .HasComment("内容。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("LikeCount") + .HasColumnType("integer") + .HasComment("点赞数。"); + + b.Property("MediaJson") + .HasColumnType("text") + .HasComment("媒体资源 JSON。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("Title") + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("标题。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "AuthorUserId", "CreatedAt"); + + b.ToTable("community_posts", null, t => + { + t.HasComment("社区动态。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Engagement.Entities.CommunityReaction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("PostId") + .HasColumnType("uuid") + .HasComment("动态 ID。"); + + b.Property("ReactedAt") + .HasColumnType("timestamp with time zone") + .HasComment("时间戳。"); + + b.Property("ReactionType") + .HasColumnType("integer") + .HasComment("反应类型。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("UserId") + .HasColumnType("uuid") + .HasComment("用户 ID。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "PostId", "UserId") + .IsUnique(); + + b.ToTable("community_reactions", null, t => + { + t.HasComment("社区互动反馈。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.GroupBuying.Entities.GroupOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CancelledAt") + .HasColumnType("timestamp with time zone") + .HasComment("取消时间。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("CurrentCount") + .HasColumnType("integer") + .HasComment("当前已参与人数。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("EndAt") + .HasColumnType("timestamp with time zone") + .HasComment("结束时间。"); + + b.Property("GroupOrderNo") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("拼单编号。"); + + b.Property("GroupPrice") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("拼团价格。"); + + b.Property("LeaderUserId") + .HasColumnType("uuid") + .HasComment("团长用户 ID。"); + + b.Property("ProductId") + .HasColumnType("uuid") + .HasComment("关联商品或套餐。"); + + b.Property("StartAt") + .HasColumnType("timestamp with time zone") + .HasComment("开始时间。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("拼团状态。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("门店标识。"); + + b.Property("SucceededAt") + .HasColumnType("timestamp with time zone") + .HasComment("成团时间。"); + + b.Property("TargetCount") + .HasColumnType("integer") + .HasComment("成团需要的人数。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "GroupOrderNo") + .IsUnique(); + + b.ToTable("group_orders", null, t => + { + t.HasComment("拼单活动。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.GroupBuying.Entities.GroupParticipant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("GroupOrderId") + .HasColumnType("uuid") + .HasComment("拼单活动标识。"); + + b.Property("JoinedAt") + .HasColumnType("timestamp with time zone") + .HasComment("参与时间。"); + + b.Property("OrderId") + .HasColumnType("uuid") + .HasComment("对应订单标识。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("参与状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("UserId") + .HasColumnType("uuid") + .HasComment("用户标识。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "GroupOrderId", "UserId") + .IsUnique(); + + b.ToTable("group_participants", null, t => + { + t.HasComment("拼单参与者。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Inventory.Entities.InventoryAdjustment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AdjustmentType") + .HasColumnType("integer") + .HasComment("调整类型。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("InventoryItemId") + .HasColumnType("uuid") + .HasComment("对应的库存记录标识。"); + + b.Property("OccurredAt") + .HasColumnType("timestamp with time zone") + .HasComment("发生时间。"); + + b.Property("OperatorId") + .HasColumnType("uuid") + .HasComment("操作人标识。"); + + b.Property("Quantity") + .HasColumnType("integer") + .HasComment("调整数量,正数增加,负数减少。"); + + b.Property("Reason") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("原因说明。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "InventoryItemId", "OccurredAt"); + + b.ToTable("inventory_adjustments", null, t => + { + t.HasComment("库存调整记录。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Inventory.Entities.InventoryBatch", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("BatchNumber") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("批次编号。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("ExpireDate") + .HasColumnType("timestamp with time zone") + .HasComment("过期日期。"); + + b.Property("ProductSkuId") + .HasColumnType("uuid") + .HasComment("SKU 标识。"); + + b.Property("ProductionDate") + .HasColumnType("timestamp with time zone") + .HasComment("生产日期。"); + + b.Property("Quantity") + .HasColumnType("integer") + .HasComment("入库数量。"); + + b.Property("RemainingQuantity") + .HasColumnType("integer") + .HasComment("剩余数量。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("门店标识。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId", "ProductSkuId", "BatchNumber") + .IsUnique(); + + b.ToTable("inventory_batches", null, t => + { + t.HasComment("SKU 批次信息。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Inventory.Entities.InventoryItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("BatchNumber") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("批次编号,可为空表示混批。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("ExpireDate") + .HasColumnType("timestamp with time zone") + .HasComment("过期日期。"); + + b.Property("Location") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("储位或仓位信息。"); + + b.Property("ProductSkuId") + .HasColumnType("uuid") + .HasComment("SKU 标识。"); + + b.Property("QuantityOnHand") + .HasColumnType("integer") + .HasComment("可用库存。"); + + b.Property("QuantityReserved") + .HasColumnType("integer") + .HasComment("已锁定库存(订单占用)。"); + + b.Property("SafetyStock") + .HasColumnType("integer") + .HasComment("安全库存阈值。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("门店标识。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId", "ProductSkuId", "BatchNumber"); + + b.ToTable("inventory_items", null, t => + { + t.HasComment("SKU 在门店的库存信息。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Membership.Entities.MemberGrowthLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("ChangeValue") + .HasColumnType("integer") + .HasComment("变动数量。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("CurrentValue") + .HasColumnType("integer") + .HasComment("当前成长值。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("MemberId") + .HasColumnType("uuid") + .HasComment("会员标识。"); + + b.Property("Notes") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("备注。"); + + b.Property("OccurredAt") + .HasColumnType("timestamp with time zone") + .HasComment("发生时间。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "MemberId", "OccurredAt"); + + b.ToTable("member_growth_logs", null, t => + { + t.HasComment("成长值变动日志。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Membership.Entities.MemberPointLedger", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("BalanceAfterChange") + .HasColumnType("integer") + .HasComment("变动后余额。"); + + b.Property("ChangeAmount") + .HasColumnType("integer") + .HasComment("变动数量,可为负值。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("ExpireAt") + .HasColumnType("timestamp with time zone") + .HasComment("过期时间(如适用)。"); + + b.Property("MemberId") + .HasColumnType("uuid") + .HasComment("会员标识。"); + + b.Property("OccurredAt") + .HasColumnType("timestamp with time zone") + .HasComment("发生时间。"); + + b.Property("Reason") + .HasColumnType("integer") + .HasComment("变动原因。"); + + b.Property("SourceId") + .HasColumnType("uuid") + .HasComment("来源 ID(订单、活动等)。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "MemberId", "OccurredAt"); + + b.ToTable("member_point_ledgers", null, t => + { + t.HasComment("积分变动流水。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Membership.Entities.MemberProfile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AvatarUrl") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("头像。"); + + b.Property("BirthDate") + .HasColumnType("timestamp with time zone") + .HasComment("生日。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("GrowthValue") + .HasColumnType("integer") + .HasComment("成长值/经验值。"); + + b.Property("JoinedAt") + .HasColumnType("timestamp with time zone") + .HasComment("注册时间。"); + + b.Property("MemberTierId") + .HasColumnType("uuid") + .HasComment("当前会员等级 ID。"); + + b.Property("Mobile") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("手机号。"); + + b.Property("Nickname") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("昵称。"); + + b.Property("PointsBalance") + .HasColumnType("integer") + .HasComment("会员积分余额。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("会员状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("UserId") + .HasColumnType("uuid") + .HasComment("用户标识。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Mobile") + .IsUnique(); + + b.ToTable("member_profiles", null, t => + { + t.HasComment("会员档案。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Membership.Entities.MemberTier", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("BenefitsJson") + .IsRequired() + .HasColumnType("text") + .HasComment("等级权益(JSON)。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("等级名称。"); + + b.Property("RequiredGrowth") + .HasColumnType("integer") + .HasComment("所需成长值。"); + + b.Property("SortOrder") + .HasColumnType("integer") + .HasComment("排序值。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Name") + .IsUnique(); + + b.ToTable("member_tiers", null, t => + { + t.HasComment("会员等级定义。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Merchants.Entities.Merchant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("Address") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("详细地址。"); + + b.Property("BrandAlias") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("品牌简称或别名。"); + + b.Property("BrandName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("品牌名称(对外展示)。"); + + b.Property("BusinessLicenseImageUrl") + .HasColumnType("text") + .HasComment("营业执照扫描件地址。"); + + b.Property("BusinessLicenseNumber") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("营业执照号。"); + + b.Property("Category") + .HasColumnType("text") + .HasComment("品牌所属品类,如火锅、咖啡等。"); + + b.Property("City") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("所在城市。"); + + b.Property("ContactEmail") + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("联系邮箱。"); + + b.Property("ContactPhone") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("联系电话。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("District") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("所在区县。"); + + b.Property("JoinedAt") + .HasColumnType("timestamp with time zone") + .HasComment("入驻时间。"); + + b.Property("LastReviewedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次审核时间。"); + + b.Property("Latitude") + .HasColumnType("double precision") + .HasComment("纬度信息。"); + + b.Property("LegalPerson") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("法人或负责人姓名。"); + + b.Property("LogoUrl") + .HasColumnType("text") + .HasComment("品牌 Logo。"); + + b.Property("Longitude") + .HasColumnType("double precision") + .HasComment("经度信息。"); + + b.Property("Province") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("所在省份。"); + + b.Property("ReviewRemarks") + .HasMaxLength(512) + .HasColumnType("character varying(512)") + .HasComment("审核备注或驳回原因。"); + + b.Property("ServicePhone") + .HasColumnType("text") + .HasComment("客服电话。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("入驻状态。"); + + b.Property("SupportEmail") + .HasColumnType("text") + .HasComment("客服邮箱。"); + + b.Property("TaxNumber") + .HasColumnType("text") + .HasComment("税号/统一社会信用代码。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId"); + + b.ToTable("merchants", null, t => + { + t.HasComment("商户主体信息,承载入驻和资质审核结果。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Merchants.Entities.MerchantContract", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("ContractNumber") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("合同编号。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("EndDate") + .HasColumnType("timestamp with time zone") + .HasComment("合同结束时间。"); + + b.Property("FileUrl") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("character varying(512)") + .HasComment("合同文件存储地址。"); + + b.Property("MerchantId") + .HasColumnType("uuid") + .HasComment("所属商户标识。"); + + b.Property("SignedAt") + .HasColumnType("timestamp with time zone") + .HasComment("签署时间。"); + + b.Property("StartDate") + .HasColumnType("timestamp with time zone") + .HasComment("合同开始时间。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("合同状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("TerminatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("终止时间。"); + + b.Property("TerminationReason") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("终止原因。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "MerchantId", "ContractNumber") + .IsUnique(); + + b.ToTable("merchant_contracts", null, t => + { + t.HasComment("商户合同记录。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Merchants.Entities.MerchantDocument", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("DocumentNumber") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("证照编号。"); + + b.Property("DocumentType") + .HasColumnType("integer") + .HasComment("证照类型。"); + + b.Property("ExpiresAt") + .HasColumnType("timestamp with time zone") + .HasComment("到期日期。"); + + b.Property("FileUrl") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("character varying(512)") + .HasComment("证照文件链接。"); + + b.Property("IssuedAt") + .HasColumnType("timestamp with time zone") + .HasComment("签发日期。"); + + b.Property("MerchantId") + .HasColumnType("uuid") + .HasComment("所属商户标识。"); + + b.Property("Remarks") + .HasColumnType("text") + .HasComment("审核备注或驳回原因。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("审核状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "MerchantId", "DocumentType"); + + b.ToTable("merchant_documents", null, t => + { + t.HasComment("商户提交的资质或证照材料。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Merchants.Entities.MerchantStaff", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("Email") + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("邮箱地址。"); + + b.Property("IdentityUserId") + .HasColumnType("uuid") + .HasComment("登录账号 ID(指向统一身份体系)。"); + + b.Property("MerchantId") + .HasColumnType("uuid") + .HasComment("所属商户标识。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("员工姓名。"); + + b.Property("PermissionsJson") + .HasColumnType("text") + .HasComment("自定义权限(JSON)。"); + + b.Property("Phone") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("手机号。"); + + b.Property("RoleType") + .HasColumnType("integer") + .HasComment("员工角色类型。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("员工状态。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("可选的关联门店 ID。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "MerchantId", "Phone"); + + b.ToTable("merchant_staff", null, t => + { + t.HasComment("商户员工账号,支持门店维度分配。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Navigation.Entities.MapLocation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("Address") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("地址。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("Landmark") + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("打车/导航落点描述。"); + + b.Property("Latitude") + .HasColumnType("double precision") + .HasComment("纬度。"); + + b.Property("Longitude") + .HasColumnType("double precision") + .HasComment("经度。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("名称。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("关联门店 ID,可空表示独立 POI。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId"); + + b.ToTable("map_locations", null, t => + { + t.HasComment("地图 POI 信息,用于门店定位和推荐。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Navigation.Entities.NavigationRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("Channel") + .HasColumnType("integer") + .HasComment("来源通道(小程序、H5 等)。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("RequestedAt") + .HasColumnType("timestamp with time zone") + .HasComment("请求时间。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("门店 ID。"); + + b.Property("TargetApp") + .HasColumnType("integer") + .HasComment("跳转的地图应用。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("UserId") + .HasColumnType("uuid") + .HasComment("用户 ID。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "UserId", "StoreId", "RequestedAt"); + + b.ToTable("navigation_requests", null, t => + { + t.HasComment("用户发起的导航请求日志。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Ordering.Entities.CartItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AttributesJson") + .HasColumnType("text") + .HasComment("扩展 JSON(规格、加料选项等)。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("ProductId") + .HasColumnType("uuid") + .HasComment("商品或 SKU 标识。"); + + b.Property("ProductName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("商品名称快照。"); + + b.Property("ProductSkuId") + .HasColumnType("uuid") + .HasComment("SKU 标识。"); + + b.Property("Quantity") + .HasColumnType("integer") + .HasComment("数量。"); + + b.Property("Remark") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("自定义备注(口味要求)。"); + + b.Property("ShoppingCartId") + .HasColumnType("uuid") + .HasComment("所属购物车标识。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UnitPrice") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("单价快照。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "ShoppingCartId"); + + b.ToTable("cart_items", null, t => + { + t.HasComment("购物车条目。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Ordering.Entities.CartItemAddon", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CartItemId") + .HasColumnType("uuid") + .HasComment("所属购物车条目。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("ExtraPrice") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("附加价格。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("选项名称。"); + + b.Property("OptionId") + .HasColumnType("uuid") + .HasComment("选项 ID(可对应 ProductAddonOption)。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.ToTable("cart_item_addons", null, t => + { + t.HasComment("购物车条目的加料/附加项。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Ordering.Entities.CheckoutSession", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("ExpiresAt") + .HasColumnType("timestamp with time zone") + .HasComment("过期时间(UTC)。"); + + b.Property("SessionToken") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("会话 Token。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("会话状态。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("门店标识。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("UserId") + .HasColumnType("uuid") + .HasComment("用户标识。"); + + b.Property("ValidationResultJson") + .IsRequired() + .HasColumnType("text") + .HasComment("校验结果明细 JSON。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "SessionToken") + .IsUnique(); + + b.ToTable("checkout_sessions", null, t => + { + t.HasComment("结账会话,记录校验上下文。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Ordering.Entities.ShoppingCart", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("DeliveryPreference") + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("履约方式(堂食/自提/配送)缓存。"); + + b.Property("LastModifiedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次修改时间(UTC)。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("购物车状态,包含正常/锁定。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("门店标识。"); + + b.Property("TableContext") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("桌码或场景标识(扫码点餐)。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("UserId") + .HasColumnType("uuid") + .HasComment("用户标识。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "UserId", "StoreId") + .IsUnique(); + + b.ToTable("shopping_carts", null, t => + { + t.HasComment("用户购物车,按租户/门店隔离。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Orders.Entities.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CancelReason") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("取消原因。"); + + b.Property("CancelledAt") + .HasColumnType("timestamp with time zone") + .HasComment("取消时间。"); + + b.Property("Channel") + .HasColumnType("integer") + .HasComment("下单渠道。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("CustomerName") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("顾客姓名。"); + + b.Property("CustomerPhone") + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("顾客手机号。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("DeliveryType") + .HasColumnType("integer") + .HasComment("履约类型。"); + + b.Property("DiscountAmount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("优惠金额。"); + + b.Property("FinishedAt") + .HasColumnType("timestamp with time zone") + .HasComment("完成时间。"); + + b.Property("ItemsAmount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("商品总额。"); + + b.Property("OrderNo") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("订单号。"); + + b.Property("PaidAmount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("实付金额。"); + + b.Property("PaidAt") + .HasColumnType("timestamp with time zone") + .HasComment("支付时间。"); + + b.Property("PayableAmount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("应付金额。"); + + b.Property("PaymentStatus") + .HasColumnType("integer") + .HasComment("支付状态。"); + + b.Property("QueueNumber") + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("排队号(如有)。"); + + b.Property("Remark") + .HasMaxLength(512) + .HasColumnType("character varying(512)") + .HasComment("备注。"); + + b.Property("ReservationId") + .HasColumnType("uuid") + .HasComment("预约 ID。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("当前状态。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("门店。"); + + b.Property("TableNo") + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("就餐桌号。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "OrderNo") + .IsUnique(); + + b.HasIndex("TenantId", "StoreId", "Status"); + + b.ToTable("orders", null, t => + { + t.HasComment("交易订单。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Orders.Entities.OrderItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AttributesJson") + .HasColumnType("text") + .HasComment("自定义属性 JSON。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("DiscountAmount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("折扣金额。"); + + b.Property("OrderId") + .HasColumnType("uuid") + .HasComment("订单 ID。"); + + b.Property("ProductId") + .HasColumnType("uuid") + .HasComment("商品 ID。"); + + b.Property("ProductName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("商品名称。"); + + b.Property("Quantity") + .HasColumnType("integer") + .HasComment("数量。"); + + b.Property("SkuName") + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("SKU/规格描述。"); + + b.Property("SubTotal") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("小计。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("Unit") + .HasMaxLength(16) + .HasColumnType("character varying(16)") + .HasComment("单位。"); + + b.Property("UnitPrice") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("单价。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("TenantId", "OrderId"); + + b.ToTable("order_items", null, t => + { + t.HasComment("订单明细。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Orders.Entities.OrderStatusHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("Notes") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("备注信息。"); + + b.Property("OccurredAt") + .HasColumnType("timestamp with time zone") + .HasComment("发生时间。"); + + b.Property("OperatorId") + .HasColumnType("uuid") + .HasComment("操作人标识(可为空表示系统)。"); + + b.Property("OrderId") + .HasColumnType("uuid") + .HasComment("订单标识。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("变更后的状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "OrderId", "OccurredAt"); + + b.ToTable("order_status_histories", null, t => + { + t.HasComment("订单状态流转记录。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Orders.Entities.RefundRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("申请金额。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("OrderId") + .HasColumnType("uuid") + .HasComment("关联订单标识。"); + + b.Property("ProcessedAt") + .HasColumnType("timestamp with time zone") + .HasComment("审核完成时间。"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("申请原因。"); + + b.Property("RefundNo") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("退款单号。"); + + b.Property("RequestedAt") + .HasColumnType("timestamp with time zone") + .HasComment("用户提交时间。"); + + b.Property("ReviewNotes") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("审核备注。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("退款状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "RefundNo") + .IsUnique(); + + b.ToTable("refund_requests", null, t => + { + t.HasComment("售后/退款申请。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Payments.Entities.PaymentRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("支付金额。"); + + b.Property("ChannelTransactionId") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("第三方渠道单号。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("Method") + .HasColumnType("integer") + .HasComment("支付方式。"); + + b.Property("OrderId") + .HasColumnType("uuid") + .HasComment("关联订单。"); + + b.Property("PaidAt") + .HasColumnType("timestamp with time zone") + .HasComment("支付完成时间。"); + + b.Property("Payload") + .HasColumnType("text") + .HasComment("原始回调内容。"); + + b.Property("Remark") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("错误/备注。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("支付状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("TradeNo") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("平台交易号。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "OrderId"); + + b.ToTable("payment_records", null, t => + { + t.HasComment("支付流水。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Payments.Entities.PaymentRefundRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("退款金额。"); + + b.Property("ChannelRefundId") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("渠道退款流水号。"); + + b.Property("CompletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("完成时间。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("OrderId") + .HasColumnType("uuid") + .HasComment("关联订单标识。"); + + b.Property("Payload") + .HasColumnType("text") + .HasComment("渠道返回的原始数据 JSON。"); + + b.Property("PaymentRecordId") + .HasColumnType("uuid") + .HasComment("原支付记录标识。"); + + b.Property("RequestedAt") + .HasColumnType("timestamp with time zone") + .HasComment("退款请求时间。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("退款状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "PaymentRecordId"); + + b.ToTable("payment_refund_records", null, t => + { + t.HasComment("支付渠道退款流水。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Products.Entities.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CategoryId") + .HasColumnType("uuid") + .HasComment("所属分类。"); + + b.Property("CoverImage") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("主图。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("Description") + .HasColumnType("text") + .HasComment("商品描述。"); + + b.Property("EnableDelivery") + .HasColumnType("boolean") + .HasComment("支持配送。"); + + b.Property("EnableDineIn") + .HasColumnType("boolean") + .HasComment("支持堂食。"); + + b.Property("EnablePickup") + .HasColumnType("boolean") + .HasComment("支持自提。"); + + b.Property("GalleryImages") + .HasMaxLength(1024) + .HasColumnType("character varying(1024)") + .HasComment("Gallery 图片逗号分隔。"); + + b.Property("IsFeatured") + .HasColumnType("boolean") + .HasComment("是否热门推荐。"); + + b.Property("MaxQuantityPerOrder") + .HasColumnType("integer") + .HasComment("最大每单限购。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("商品名称。"); + + b.Property("OriginalPrice") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("原价。"); + + b.Property("Price") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("现价。"); + + b.Property("SpuCode") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("商品编码。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("商品状态。"); + + b.Property("StockQuantity") + .HasColumnType("integer") + .HasComment("库存数量(可选)。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("所属门店。"); + + b.Property("Subtitle") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("副标题/卖点。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("Unit") + .HasMaxLength(16) + .HasColumnType("character varying(16)") + .HasComment("售卖单位(份/杯等)。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "SpuCode") + .IsUnique(); + + b.HasIndex("TenantId", "StoreId"); + + b.ToTable("products", null, t => + { + t.HasComment("商品(SPU)信息。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Products.Entities.ProductAddonGroup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("IsRequired") + .HasColumnType("boolean") + .HasComment("是否必选。"); + + b.Property("MaxSelect") + .HasColumnType("integer") + .HasComment("最大选择数量。"); + + b.Property("MinSelect") + .HasColumnType("integer") + .HasComment("最小选择数量。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("分组名称。"); + + b.Property("ProductId") + .HasColumnType("uuid") + .HasComment("所属商品。"); + + b.Property("SelectionType") + .HasColumnType("integer") + .HasComment("选择类型。"); + + b.Property("SortOrder") + .HasColumnType("integer") + .HasComment("排序值。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "ProductId", "Name"); + + b.ToTable("product_addon_groups", null, t => + { + t.HasComment("加料/做法分组。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Products.Entities.ProductAddonOption", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AddonGroupId") + .HasColumnType("uuid") + .HasComment("所属加料分组。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("ExtraPrice") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("附加价格。"); + + b.Property("IsDefault") + .HasColumnType("boolean") + .HasComment("是否默认选项。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("选项名称。"); + + b.Property("SortOrder") + .HasColumnType("integer") + .HasComment("排序。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.ToTable("product_addon_options", null, t => + { + t.HasComment("加料选项。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Products.Entities.ProductAttributeGroup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("IsRequired") + .HasColumnType("boolean") + .HasComment("是否必选。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("分组名称,例如“辣度”“份量”。"); + + b.Property("SelectionType") + .HasColumnType("integer") + .HasComment("选择类型(单选/多选)。"); + + b.Property("SortOrder") + .HasColumnType("integer") + .HasComment("显示排序。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("关联门店,可为空表示所有门店共享。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId", "Name"); + + b.ToTable("product_attribute_groups", null, t => + { + t.HasComment("商品规格/属性分组。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Products.Entities.ProductAttributeOption", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AttributeGroupId") + .HasColumnType("uuid") + .HasComment("所属规格组。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("ExtraPrice") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("附加价格。"); + + b.Property("IsDefault") + .HasColumnType("boolean") + .HasComment("是否默认选中。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("选项名称。"); + + b.Property("SortOrder") + .HasColumnType("integer") + .HasComment("排序。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "AttributeGroupId", "Name") + .IsUnique(); + + b.ToTable("product_attribute_options", null, t => + { + t.HasComment("商品规格选项。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Products.Entities.ProductCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("Description") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("分类描述。"); + + b.Property("IsEnabled") + .HasColumnType("boolean") + .HasComment("是否启用。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("分类名称。"); + + b.Property("SortOrder") + .HasColumnType("integer") + .HasComment("排序值。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("所属门店。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId"); + + b.ToTable("product_categories", null, t => + { + t.HasComment("商品分类。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Products.Entities.ProductMediaAsset", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("Caption") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("描述或标题。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("MediaType") + .HasColumnType("integer") + .HasComment("媒体类型。"); + + b.Property("ProductId") + .HasColumnType("uuid") + .HasComment("商品标识。"); + + b.Property("SortOrder") + .HasColumnType("integer") + .HasComment("排序。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("Url") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("character varying(512)") + .HasComment("媒资链接。"); + + b.HasKey("Id"); + + b.ToTable("product_media_assets", null, t => + { + t.HasComment("商品媒资素材。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Products.Entities.ProductPricingRule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("ConditionsJson") + .IsRequired() + .HasColumnType("text") + .HasComment("条件描述(JSON),如会员等级、渠道等。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("EndTime") + .HasColumnType("timestamp with time zone") + .HasComment("生效结束时间。"); + + b.Property("Price") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("特殊价格。"); + + b.Property("ProductId") + .HasColumnType("uuid") + .HasComment("所属商品。"); + + b.Property("RuleType") + .HasColumnType("integer") + .HasComment("策略类型。"); + + b.Property("StartTime") + .HasColumnType("timestamp with time zone") + .HasComment("生效开始时间。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("WeekdaysJson") + .HasColumnType("text") + .HasComment("生效星期(JSON 数组)。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "ProductId", "RuleType"); + + b.ToTable("product_pricing_rules", null, t => + { + t.HasComment("商品价格策略,支持会员价/时段价等。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Products.Entities.ProductSku", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AttributesJson") + .IsRequired() + .HasColumnType("text") + .HasComment("规格属性 JSON(记录选项 ID)。"); + + b.Property("Barcode") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("条形码。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("OriginalPrice") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("原价。"); + + b.Property("Price") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("售价。"); + + b.Property("ProductId") + .HasColumnType("uuid") + .HasComment("所属商品标识。"); + + b.Property("SkuCode") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("SKU 编码。"); + + b.Property("StockQuantity") + .HasColumnType("integer") + .HasComment("可售库存。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("Weight") + .HasPrecision(10, 3) + .HasColumnType("numeric(10,3)") + .HasComment("重量(千克)。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "SkuCode") + .IsUnique(); + + b.ToTable("product_skus", null, t => + { + t.HasComment("商品 SKU,记录具体规格组合价格。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Queues.Entities.QueueTicket", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CalledAt") + .HasColumnType("timestamp with time zone") + .HasComment("叫号时间。"); + + b.Property("CancelledAt") + .HasColumnType("timestamp with time zone") + .HasComment("取消时间。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("EstimatedWaitMinutes") + .HasColumnType("integer") + .HasComment("预计等待分钟。"); + + b.Property("ExpiredAt") + .HasColumnType("timestamp with time zone") + .HasComment("过号时间。"); + + b.Property("PartySize") + .HasColumnType("integer") + .HasComment("就餐人数。"); + + b.Property("Remark") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("备注。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("状态。"); + + b.Property("StoreId") + .HasColumnType("uuid"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("TicketNumber") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("排队编号。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId"); + + b.HasIndex("TenantId", "StoreId", "TicketNumber") + .IsUnique(); + + b.ToTable("queue_tickets", null, t => + { + t.HasComment("排队叫号。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Reservations.Entities.Reservation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CancelledAt") + .HasColumnType("timestamp with time zone") + .HasComment("取消时间。"); + + b.Property("CheckInCode") + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("核销码/到店码。"); + + b.Property("CheckedInAt") + .HasColumnType("timestamp with time zone") + .HasComment("实际签到时间。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("CustomerName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("客户姓名。"); + + b.Property("CustomerPhone") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("联系电话。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("PeopleCount") + .HasColumnType("integer") + .HasComment("用餐人数。"); + + b.Property("Remark") + .HasMaxLength(512) + .HasColumnType("character varying(512)") + .HasComment("备注。"); + + b.Property("ReservationNo") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("预约号。"); + + b.Property("ReservationTime") + .HasColumnType("timestamp with time zone") + .HasComment("预约时间(UTC)。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("状态。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("门店。"); + + b.Property("TablePreference") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("桌型/标签。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "ReservationNo") + .IsUnique(); + + b.HasIndex("TenantId", "StoreId"); + + b.ToTable("reservations", null, t => + { + t.HasComment("预约/预订记录。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Stores.Entities.Store", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("Address") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("详细地址。"); + + b.Property("Announcement") + .HasMaxLength(512) + .HasColumnType("character varying(512)") + .HasComment("门店公告。"); + + b.Property("BusinessHours") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("门店营业时段描述(备用字符串)。"); + + b.Property("City") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("所在城市。"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("门店编码,便于扫码及外部对接。"); + + b.Property("Country") + .HasColumnType("text") + .HasComment("所在国家或地区。"); + + b.Property("CoverImageUrl") + .HasColumnType("text") + .HasComment("门店海报。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("DeliveryRadiusKm") + .HasPrecision(6, 2) + .HasColumnType("numeric(6,2)") + .HasComment("默认配送半径(公里)。"); + + b.Property("Description") + .HasColumnType("text") + .HasComment("门店描述或公告。"); + + b.Property("District") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("区县信息。"); + + b.Property("Latitude") + .HasColumnType("double precision") + .HasComment("纬度。"); + + b.Property("Longitude") + .HasColumnType("double precision") + .HasComment("高德/腾讯地图经度。"); + + b.Property("ManagerName") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("门店负责人姓名。"); + + b.Property("MerchantId") + .HasColumnType("uuid") + .HasComment("所属商户标识。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("门店名称。"); + + b.Property("Phone") + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("联系电话。"); + + b.Property("Province") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("所在省份。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("门店当前运营状态。"); + + b.Property("SupportsDelivery") + .HasColumnType("boolean") + .HasComment("是否支持配送。"); + + b.Property("SupportsDineIn") + .HasColumnType("boolean") + .HasComment("是否支持堂食。"); + + b.Property("SupportsPickup") + .HasColumnType("boolean") + .HasComment("是否支持自提。"); + + b.Property("SupportsQueueing") + .HasColumnType("boolean") + .HasComment("支持排队叫号。"); + + b.Property("SupportsReservation") + .HasColumnType("boolean") + .HasComment("支持预约。"); + + b.Property("Tags") + .HasColumnType("text") + .HasComment("门店标签(逗号分隔)。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Code") + .IsUnique(); + + b.HasIndex("TenantId", "MerchantId"); + + b.ToTable("stores", null, t => + { + t.HasComment("门店信息,承载营业配置与能力。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Stores.Entities.StoreBusinessHour", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CapacityLimit") + .HasColumnType("integer") + .HasComment("最大接待容量或单量限制。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DayOfWeek") + .HasColumnType("integer") + .HasComment("星期几,0 表示周日。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("EndTime") + .HasColumnType("interval") + .HasComment("结束时间(本地时间)。"); + + b.Property("HourType") + .HasColumnType("integer") + .HasComment("时段类型(正常营业、休息、预约等)。"); + + b.Property("Notes") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("备注。"); + + b.Property("StartTime") + .HasColumnType("interval") + .HasComment("开始时间(本地时间)。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("门店标识。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId", "DayOfWeek"); + + b.ToTable("store_business_hours", null, t => + { + t.HasComment("门店营业时段配置。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Stores.Entities.StoreDeliveryZone", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("DeliveryFee") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("配送费。"); + + b.Property("EstimatedMinutes") + .HasColumnType("integer") + .HasComment("预计送达分钟。"); + + b.Property("MinimumOrderAmount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("起送价。"); + + b.Property("PolygonGeoJson") + .IsRequired() + .HasColumnType("text") + .HasComment("GeoJSON 表示的多边形范围。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("门店标识。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("ZoneName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("区域名称。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId", "ZoneName"); + + b.ToTable("store_delivery_zones", null, t => + { + t.HasComment("门店配送范围配置。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Stores.Entities.StoreEmployeeShift", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("EndTime") + .HasColumnType("interval") + .HasComment("结束时间。"); + + b.Property("Notes") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("备注。"); + + b.Property("RoleType") + .HasColumnType("integer") + .HasComment("排班角色。"); + + b.Property("ShiftDate") + .HasColumnType("timestamp with time zone") + .HasComment("班次日期。"); + + b.Property("StaffId") + .HasColumnType("uuid") + .HasComment("员工标识。"); + + b.Property("StartTime") + .HasColumnType("interval") + .HasComment("开始时间。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("门店标识。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId", "ShiftDate", "StaffId") + .IsUnique(); + + b.ToTable("store_employee_shifts", null, t => + { + t.HasComment("门店员工排班记录。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Stores.Entities.StoreHoliday", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("Date") + .HasColumnType("timestamp with time zone") + .HasComment("日期。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("IsClosed") + .HasColumnType("boolean") + .HasComment("是否全天闭店。"); + + b.Property("Reason") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("说明内容。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("门店标识。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId", "Date") + .IsUnique(); + + b.ToTable("store_holidays", null, t => + { + t.HasComment("门店休息日或特殊营业日。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Stores.Entities.StoreTable", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AreaId") + .HasColumnType("uuid") + .HasComment("所在区域 ID。"); + + b.Property("Capacity") + .HasColumnType("integer") + .HasComment("可容纳人数。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("QrCodeUrl") + .HasMaxLength(512) + .HasColumnType("character varying(512)") + .HasComment("桌码二维码地址。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("当前桌台状态。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("门店标识。"); + + b.Property("TableCode") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("桌码。"); + + b.Property("Tags") + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("桌台标签(堂食、快餐等)。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId", "TableCode") + .IsUnique(); + + b.ToTable("store_tables", null, t => + { + t.HasComment("桌台信息与二维码绑定。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Stores.Entities.StoreTableArea", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("Description") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("区域描述。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("区域名称。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("门店标识。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId", "Name") + .IsUnique(); + + b.ToTable("store_table_areas", null, t => + { + t.HasComment("门店桌台区域配置。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Tenants.Entities.Tenant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("Address") + .HasColumnType("text") + .HasComment("详细地址信息。"); + + b.Property("City") + .HasColumnType("text") + .HasComment("所在城市。"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("租户短编码,作为跨系统引用的唯一标识。"); + + b.Property("ContactEmail") + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("主联系人邮箱。"); + + b.Property("ContactName") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("主联系人姓名。"); + + b.Property("ContactPhone") + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("主联系人电话。"); + + b.Property("Country") + .HasColumnType("text") + .HasComment("所在国家/地区。"); + + b.Property("CoverImageUrl") + .HasColumnType("text") + .HasComment("品牌海报或封面图。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("EffectiveFrom") + .HasColumnType("timestamp with time zone") + .HasComment("服务生效时间(UTC)。"); + + b.Property("EffectiveTo") + .HasColumnType("timestamp with time zone") + .HasComment("服务到期时间(UTC)。"); + + b.Property("Industry") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("所属行业,如餐饮、零售等。"); + + b.Property("LegalEntityName") + .HasColumnType("text") + .HasComment("法人或公司主体名称。"); + + b.Property("LogoUrl") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("LOGO 图片地址。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("租户全称或品牌名称。"); + + b.Property("PrimaryOwnerUserId") + .HasColumnType("uuid") + .HasComment("系统内对应的租户所有者账号 ID。"); + + b.Property("Province") + .HasColumnType("text") + .HasComment("所在省份或州。"); + + b.Property("Remarks") + .HasMaxLength(512) + .HasColumnType("character varying(512)") + .HasComment("备注信息,用于运营记录特殊说明。"); + + b.Property("ShortName") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("对外展示的简称。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("租户当前状态,涵盖审核、启用、停用等场景。"); + + b.Property("SuspendedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次暂停服务时间。"); + + b.Property("SuspensionReason") + .HasColumnType("text") + .HasComment("暂停或终止的原因说明。"); + + b.Property("Tags") + .HasColumnType("text") + .HasComment("业务标签集合(逗号分隔)。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("Website") + .HasColumnType("text") + .HasComment("官网或主要宣传链接。"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("tenants", null, t => + { + t.HasComment("平台租户信息,描述租户的生命周期与基础资料。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Tenants.Entities.TenantBillingStatement", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AmountDue") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("应付金额。"); + + b.Property("AmountPaid") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("实付金额。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("DueDate") + .HasColumnType("timestamp with time zone") + .HasComment("到期日。"); + + b.Property("LineItemsJson") + .HasColumnType("text") + .HasComment("账单明细 JSON,记录各项费用。"); + + b.Property("PeriodEnd") + .HasColumnType("timestamp with time zone") + .HasComment("账单周期结束时间。"); + + b.Property("PeriodStart") + .HasColumnType("timestamp with time zone") + .HasComment("账单周期开始时间。"); + + b.Property("StatementNo") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("账单编号,供对账查询。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("当前付款状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StatementNo") + .IsUnique(); + + b.ToTable("tenant_billing_statements", null, t => + { + t.HasComment("租户账单,用于呈现周期性收费。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Tenants.Entities.TenantNotification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("Channel") + .HasColumnType("integer") + .HasComment("发布通道(站内、邮件、短信等)。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("Message") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("character varying(1024)") + .HasComment("通知正文。"); + + b.Property("MetadataJson") + .HasColumnType("text") + .HasComment("附加元数据 JSON。"); + + b.Property("ReadAt") + .HasColumnType("timestamp with time zone") + .HasComment("租户是否已阅读。"); + + b.Property("SentAt") + .HasColumnType("timestamp with time zone") + .HasComment("推送时间。"); + + b.Property("Severity") + .HasColumnType("integer") + .HasComment("通知重要级别。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("通知标题。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Channel", "SentAt"); + + b.ToTable("tenant_notifications", null, t => + { + t.HasComment("面向租户的站内通知或消息推送。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Tenants.Entities.TenantPackage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("Description") + .HasMaxLength(512) + .HasColumnType("character varying(512)") + .HasComment("套餐描述,包含适用场景、权益等。"); + + b.Property("FeaturePoliciesJson") + .HasColumnType("text") + .HasComment("权益明细 JSON,记录自定义特性开关。"); + + b.Property("IsActive") + .HasColumnType("boolean") + .HasComment("是否仍可售卖。"); + + b.Property("MaxAccountCount") + .HasColumnType("integer") + .HasComment("允许创建的最大账号数。"); + + b.Property("MaxDeliveryOrders") + .HasColumnType("integer") + .HasComment("每月可调用的配送单数量上限。"); + + b.Property("MaxSmsCredits") + .HasColumnType("integer") + .HasComment("每月短信额度上限。"); + + b.Property("MaxStorageGb") + .HasColumnType("integer") + .HasComment("存储容量上限(GB)。"); + + b.Property("MaxStoreCount") + .HasColumnType("integer") + .HasComment("允许的最大门店数。"); + + b.Property("MonthlyPrice") + .HasColumnType("numeric") + .HasComment("月付价格,单位:人民币元。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("套餐名称,展示给租户的简称。"); + + b.Property("PackageType") + .HasColumnType("integer") + .HasComment("套餐分类(试用、标准、旗舰等)。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("YearlyPrice") + .HasColumnType("numeric") + .HasComment("年付价格,单位:人民币元。"); + + b.HasKey("Id"); + + b.ToTable("tenant_packages", null, t => + { + t.HasComment("平台提供的租户套餐定义。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Tenants.Entities.TenantQuotaUsage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("LastResetAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次重置时间。"); + + b.Property("LimitValue") + .HasColumnType("numeric") + .HasComment("当前配额上限。"); + + b.Property("QuotaType") + .HasColumnType("integer") + .HasComment("配额类型,例如门店数、短信条数等。"); + + b.Property("ResetCycle") + .HasColumnType("text") + .HasComment("配额刷新周期描述(如月、年)。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("UsedValue") + .HasColumnType("numeric") + .HasComment("已消耗的数量。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "QuotaType") + .IsUnique(); + + b.ToTable("tenant_quota_usages", null, t => + { + t.HasComment("租户配额使用情况快照。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Tenants.Entities.TenantSubscription", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AutoRenew") + .HasColumnType("boolean") + .HasComment("是否开启自动续费。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("EffectiveFrom") + .HasColumnType("timestamp with time zone") + .HasComment("订阅生效时间(UTC)。"); + + b.Property("EffectiveTo") + .HasColumnType("timestamp with time zone") + .HasComment("订阅到期时间(UTC)。"); + + b.Property("NextBillingDate") + .HasColumnType("timestamp with time zone") + .HasComment("下一个计费时间,配合自动续费使用。"); + + b.Property("Notes") + .HasColumnType("text") + .HasComment("运营备注信息。"); + + b.Property("ScheduledPackageId") + .HasColumnType("uuid") + .HasComment("若已排期升降配,对应的新套餐 ID。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("订阅当前状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("TenantPackageId") + .HasColumnType("uuid") + .HasComment("当前订阅关联的套餐标识。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "TenantPackageId"); + + b.ToTable("tenant_subscriptions", null, t => + { + t.HasComment("租户套餐订阅记录。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Orders.Entities.OrderItem", b => + { + b.HasOne("TakeoutSaaS.Domain.Orders.Entities.Order", null) + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Infrastructure/TakeoutSaaS.Infrastructure/App/Migrations/20251201094254_AddEntityComments.cs b/src/Infrastructure/TakeoutSaaS.Infrastructure/App/Migrations/20251201094254_AddEntityComments.cs new file mode 100644 index 0000000..38504cd --- /dev/null +++ b/src/Infrastructure/TakeoutSaaS.Infrastructure/App/Migrations/20251201094254_AddEntityComments.cs @@ -0,0 +1,22401 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace TakeoutSaaS.Infrastructure.App.Migrations +{ + /// + public partial class AddEntityComments : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterTable( + name: "ticket_comments", + comment: "工单评论/流转记录。"); + + migrationBuilder.AlterTable( + name: "tenants", + comment: "平台租户信息,描述租户的生命周期与基础资料。"); + + migrationBuilder.AlterTable( + name: "tenant_subscriptions", + comment: "租户套餐订阅记录。"); + + migrationBuilder.AlterTable( + name: "tenant_quota_usages", + comment: "租户配额使用情况快照。"); + + migrationBuilder.AlterTable( + name: "tenant_packages", + comment: "平台提供的租户套餐定义。"); + + migrationBuilder.AlterTable( + name: "tenant_notifications", + comment: "面向租户的站内通知或消息推送。"); + + migrationBuilder.AlterTable( + name: "tenant_billing_statements", + comment: "租户账单,用于呈现周期性收费。"); + + migrationBuilder.AlterTable( + name: "support_tickets", + comment: "客服工单。"); + + migrationBuilder.AlterTable( + name: "stores", + comment: "门店信息,承载营业配置与能力。"); + + migrationBuilder.AlterTable( + name: "store_tables", + comment: "桌台信息与二维码绑定。"); + + migrationBuilder.AlterTable( + name: "store_table_areas", + comment: "门店桌台区域配置。"); + + migrationBuilder.AlterTable( + name: "store_holidays", + comment: "门店休息日或特殊营业日。"); + + migrationBuilder.AlterTable( + name: "store_employee_shifts", + comment: "门店员工排班记录。"); + + migrationBuilder.AlterTable( + name: "store_delivery_zones", + comment: "门店配送范围配置。"); + + migrationBuilder.AlterTable( + name: "store_business_hours", + comment: "门店营业时段配置。"); + + migrationBuilder.AlterTable( + name: "shopping_carts", + comment: "用户购物车,按租户/门店隔离。"); + + migrationBuilder.AlterTable( + name: "reservations", + comment: "预约/预订记录。"); + + migrationBuilder.AlterTable( + name: "refund_requests", + comment: "售后/退款申请。"); + + migrationBuilder.AlterTable( + name: "queue_tickets", + comment: "排队叫号。"); + + migrationBuilder.AlterTable( + name: "promotion_campaigns", + comment: "营销活动配置。"); + + migrationBuilder.AlterTable( + name: "products", + comment: "商品(SPU)信息。"); + + migrationBuilder.AlterTable( + name: "product_skus", + comment: "商品 SKU,记录具体规格组合价格。"); + + migrationBuilder.AlterTable( + name: "product_pricing_rules", + comment: "商品价格策略,支持会员价/时段价等。"); + + migrationBuilder.AlterTable( + name: "product_media_assets", + comment: "商品媒资素材。"); + + migrationBuilder.AlterTable( + name: "product_categories", + comment: "商品分类。"); + + migrationBuilder.AlterTable( + name: "product_attribute_options", + comment: "商品规格选项。"); + + migrationBuilder.AlterTable( + name: "product_attribute_groups", + comment: "商品规格/属性分组。"); + + migrationBuilder.AlterTable( + name: "product_addon_options", + comment: "加料选项。"); + + migrationBuilder.AlterTable( + name: "product_addon_groups", + comment: "加料/做法分组。"); + + migrationBuilder.AlterTable( + name: "payment_refund_records", + comment: "支付渠道退款流水。"); + + migrationBuilder.AlterTable( + name: "payment_records", + comment: "支付流水。"); + + migrationBuilder.AlterTable( + name: "orders", + comment: "交易订单。"); + + migrationBuilder.AlterTable( + name: "order_status_histories", + comment: "订单状态流转记录。"); + + migrationBuilder.AlterTable( + name: "order_items", + comment: "订单明细。"); + + migrationBuilder.AlterTable( + name: "navigation_requests", + comment: "用户发起的导航请求日志。"); + + migrationBuilder.AlterTable( + name: "metric_snapshots", + comment: "指标快照,用于大盘展示。"); + + migrationBuilder.AlterTable( + name: "metric_definitions", + comment: "指标定义,描述可观测的数据点。"); + + migrationBuilder.AlterTable( + name: "metric_alert_rules", + comment: "指标告警规则。"); + + migrationBuilder.AlterTable( + name: "merchants", + comment: "商户主体信息,承载入驻和资质审核结果。"); + + migrationBuilder.AlterTable( + name: "merchant_staff", + comment: "商户员工账号,支持门店维度分配。"); + + migrationBuilder.AlterTable( + name: "merchant_documents", + comment: "商户提交的资质或证照材料。"); + + migrationBuilder.AlterTable( + name: "merchant_contracts", + comment: "商户合同记录。"); + + migrationBuilder.AlterTable( + name: "member_tiers", + comment: "会员等级定义。"); + + migrationBuilder.AlterTable( + name: "member_profiles", + comment: "会员档案。"); + + migrationBuilder.AlterTable( + name: "member_point_ledgers", + comment: "积分变动流水。"); + + migrationBuilder.AlterTable( + name: "member_growth_logs", + comment: "成长值变动日志。"); + + migrationBuilder.AlterTable( + name: "map_locations", + comment: "地图 POI 信息,用于门店定位和推荐。"); + + migrationBuilder.AlterTable( + name: "inventory_items", + comment: "SKU 在门店的库存信息。"); + + migrationBuilder.AlterTable( + name: "inventory_batches", + comment: "SKU 批次信息。"); + + migrationBuilder.AlterTable( + name: "inventory_adjustments", + comment: "库存调整记录。"); + + migrationBuilder.AlterTable( + name: "group_participants", + comment: "拼单参与者。"); + + migrationBuilder.AlterTable( + name: "group_orders", + comment: "拼单活动。"); + + migrationBuilder.AlterTable( + name: "delivery_orders", + comment: "配送单。"); + + migrationBuilder.AlterTable( + name: "delivery_events", + comment: "配送状态事件流水。"); + + migrationBuilder.AlterTable( + name: "coupons", + comment: "用户领取的券。"); + + migrationBuilder.AlterTable( + name: "coupon_templates", + comment: "优惠券模板。"); + + migrationBuilder.AlterTable( + name: "community_reactions", + comment: "社区互动反馈。"); + + migrationBuilder.AlterTable( + name: "community_posts", + comment: "社区动态。"); + + migrationBuilder.AlterTable( + name: "community_comments", + comment: "社区评论。"); + + migrationBuilder.AlterTable( + name: "checkout_sessions", + comment: "结账会话,记录校验上下文。"); + + migrationBuilder.AlterTable( + name: "checkin_records", + comment: "用户签到记录。"); + + migrationBuilder.AlterTable( + name: "checkin_campaigns", + comment: "签到活动配置。"); + + migrationBuilder.AlterTable( + name: "chat_sessions", + comment: "客服会话。"); + + migrationBuilder.AlterTable( + name: "chat_messages", + comment: "会话消息。"); + + migrationBuilder.AlterTable( + name: "cart_items", + comment: "购物车条目。"); + + migrationBuilder.AlterTable( + name: "cart_item_addons", + comment: "购物车条目的加料/附加项。"); + + migrationBuilder.AlterTable( + name: "affiliate_payouts", + comment: "佣金结算记录。"); + + migrationBuilder.AlterTable( + name: "affiliate_partners", + comment: "分销/推广合作伙伴。"); + + migrationBuilder.AlterTable( + name: "affiliate_orders", + comment: "分销订单记录。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "ticket_comments", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "ticket_comments", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "ticket_comments", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "SupportTicketId", + table: "ticket_comments", + type: "uuid", + nullable: false, + comment: "工单标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "IsInternal", + table: "ticket_comments", + type: "boolean", + nullable: false, + comment: "是否内部备注。", + oldClrType: typeof(bool), + oldType: "boolean"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "ticket_comments", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "ticket_comments", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "ticket_comments", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "ticket_comments", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Content", + table: "ticket_comments", + type: "character varying(1024)", + maxLength: 1024, + nullable: false, + comment: "评论内容。", + oldClrType: typeof(string), + oldType: "character varying(1024)", + oldMaxLength: 1024); + + migrationBuilder.AlterColumn( + name: "AuthorUserId", + table: "ticket_comments", + type: "uuid", + nullable: true, + comment: "评论人 ID。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "AttachmentsJson", + table: "ticket_comments", + type: "text", + nullable: true, + comment: "附件 JSON。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Id", + table: "ticket_comments", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Website", + table: "tenants", + type: "text", + nullable: true, + comment: "官网或主要宣传链接。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "tenants", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "tenants", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Tags", + table: "tenants", + type: "text", + nullable: true, + comment: "业务标签集合(逗号分隔)。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "SuspensionReason", + table: "tenants", + type: "text", + nullable: true, + comment: "暂停或终止的原因说明。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "SuspendedAt", + table: "tenants", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次暂停服务时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Status", + table: "tenants", + type: "integer", + nullable: false, + comment: "租户当前状态,涵盖审核、启用、停用等场景。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "ShortName", + table: "tenants", + type: "character varying(64)", + maxLength: 64, + nullable: true, + comment: "对外展示的简称。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Remarks", + table: "tenants", + type: "character varying(512)", + maxLength: 512, + nullable: true, + comment: "备注信息,用于运营记录特殊说明。", + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Province", + table: "tenants", + type: "text", + nullable: true, + comment: "所在省份或州。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "PrimaryOwnerUserId", + table: "tenants", + type: "uuid", + nullable: true, + comment: "系统内对应的租户所有者账号 ID。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Name", + table: "tenants", + type: "character varying(128)", + maxLength: 128, + nullable: false, + comment: "租户全称或品牌名称。", + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128); + + migrationBuilder.AlterColumn( + name: "LogoUrl", + table: "tenants", + type: "character varying(256)", + maxLength: 256, + nullable: true, + comment: "LOGO 图片地址。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "LegalEntityName", + table: "tenants", + type: "text", + nullable: true, + comment: "法人或公司主体名称。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Industry", + table: "tenants", + type: "character varying(64)", + maxLength: 64, + nullable: true, + comment: "所属行业,如餐饮、零售等。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "EffectiveTo", + table: "tenants", + type: "timestamp with time zone", + nullable: true, + comment: "服务到期时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "EffectiveFrom", + table: "tenants", + type: "timestamp with time zone", + nullable: true, + comment: "服务生效时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "tenants", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "tenants", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "tenants", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "tenants", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "CoverImageUrl", + table: "tenants", + type: "text", + nullable: true, + comment: "品牌海报或封面图。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Country", + table: "tenants", + type: "text", + nullable: true, + comment: "所在国家/地区。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ContactPhone", + table: "tenants", + type: "character varying(32)", + maxLength: 32, + nullable: true, + comment: "主联系人电话。", + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ContactName", + table: "tenants", + type: "character varying(64)", + maxLength: 64, + nullable: true, + comment: "主联系人姓名。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ContactEmail", + table: "tenants", + type: "character varying(128)", + maxLength: 128, + nullable: true, + comment: "主联系人邮箱。", + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Code", + table: "tenants", + type: "character varying(64)", + maxLength: 64, + nullable: false, + comment: "租户短编码,作为跨系统引用的唯一标识。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64); + + migrationBuilder.AlterColumn( + name: "City", + table: "tenants", + type: "text", + nullable: true, + comment: "所在城市。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Address", + table: "tenants", + type: "text", + nullable: true, + comment: "详细地址信息。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Id", + table: "tenants", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "tenant_subscriptions", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "tenant_subscriptions", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantPackageId", + table: "tenant_subscriptions", + type: "uuid", + nullable: false, + comment: "当前订阅关联的套餐标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "tenant_subscriptions", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "tenant_subscriptions", + type: "integer", + nullable: false, + comment: "订阅当前状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "ScheduledPackageId", + table: "tenant_subscriptions", + type: "uuid", + nullable: true, + comment: "若已排期升降配,对应的新套餐 ID。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Notes", + table: "tenant_subscriptions", + type: "text", + nullable: true, + comment: "运营备注信息。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "NextBillingDate", + table: "tenant_subscriptions", + type: "timestamp with time zone", + nullable: true, + comment: "下一个计费时间,配合自动续费使用。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "EffectiveTo", + table: "tenant_subscriptions", + type: "timestamp with time zone", + nullable: false, + comment: "订阅到期时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "EffectiveFrom", + table: "tenant_subscriptions", + type: "timestamp with time zone", + nullable: false, + comment: "订阅生效时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "tenant_subscriptions", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "tenant_subscriptions", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "tenant_subscriptions", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "tenant_subscriptions", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "AutoRenew", + table: "tenant_subscriptions", + type: "boolean", + nullable: false, + comment: "是否开启自动续费。", + oldClrType: typeof(bool), + oldType: "boolean"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "tenant_subscriptions", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UsedValue", + table: "tenant_quota_usages", + type: "numeric", + nullable: false, + comment: "已消耗的数量。", + oldClrType: typeof(decimal), + oldType: "numeric"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "tenant_quota_usages", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "tenant_quota_usages", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "tenant_quota_usages", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "ResetCycle", + table: "tenant_quota_usages", + type: "text", + nullable: true, + comment: "配额刷新周期描述(如月、年)。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "QuotaType", + table: "tenant_quota_usages", + type: "integer", + nullable: false, + comment: "配额类型,例如门店数、短信条数等。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "LimitValue", + table: "tenant_quota_usages", + type: "numeric", + nullable: false, + comment: "当前配额上限。", + oldClrType: typeof(decimal), + oldType: "numeric"); + + migrationBuilder.AlterColumn( + name: "LastResetAt", + table: "tenant_quota_usages", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次重置时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "tenant_quota_usages", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "tenant_quota_usages", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "tenant_quota_usages", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "tenant_quota_usages", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "tenant_quota_usages", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "YearlyPrice", + table: "tenant_packages", + type: "numeric", + nullable: true, + comment: "年付价格,单位:人民币元。", + oldClrType: typeof(decimal), + oldType: "numeric", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "tenant_packages", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "tenant_packages", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "PackageType", + table: "tenant_packages", + type: "integer", + nullable: false, + comment: "套餐分类(试用、标准、旗舰等)。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "tenant_packages", + type: "character varying(128)", + maxLength: 128, + nullable: false, + comment: "套餐名称,展示给租户的简称。", + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128); + + migrationBuilder.AlterColumn( + name: "MonthlyPrice", + table: "tenant_packages", + type: "numeric", + nullable: true, + comment: "月付价格,单位:人民币元。", + oldClrType: typeof(decimal), + oldType: "numeric", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "MaxStoreCount", + table: "tenant_packages", + type: "integer", + nullable: true, + comment: "允许的最大门店数。", + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "MaxStorageGb", + table: "tenant_packages", + type: "integer", + nullable: true, + comment: "存储容量上限(GB)。", + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "MaxSmsCredits", + table: "tenant_packages", + type: "integer", + nullable: true, + comment: "每月短信额度上限。", + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "MaxDeliveryOrders", + table: "tenant_packages", + type: "integer", + nullable: true, + comment: "每月可调用的配送单数量上限。", + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "MaxAccountCount", + table: "tenant_packages", + type: "integer", + nullable: true, + comment: "允许创建的最大账号数。", + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "IsActive", + table: "tenant_packages", + type: "boolean", + nullable: false, + comment: "是否仍可售卖。", + oldClrType: typeof(bool), + oldType: "boolean"); + + migrationBuilder.AlterColumn( + name: "FeaturePoliciesJson", + table: "tenant_packages", + type: "text", + nullable: true, + comment: "权益明细 JSON,记录自定义特性开关。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Description", + table: "tenant_packages", + type: "character varying(512)", + maxLength: 512, + nullable: true, + comment: "套餐描述,包含适用场景、权益等。", + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "tenant_packages", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "tenant_packages", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "tenant_packages", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "tenant_packages", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "tenant_packages", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "tenant_notifications", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "tenant_notifications", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Title", + table: "tenant_notifications", + type: "character varying(128)", + maxLength: 128, + nullable: false, + comment: "通知标题。", + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "tenant_notifications", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Severity", + table: "tenant_notifications", + type: "integer", + nullable: false, + comment: "通知重要级别。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "SentAt", + table: "tenant_notifications", + type: "timestamp with time zone", + nullable: false, + comment: "推送时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "ReadAt", + table: "tenant_notifications", + type: "timestamp with time zone", + nullable: true, + comment: "租户是否已阅读。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "MetadataJson", + table: "tenant_notifications", + type: "text", + nullable: true, + comment: "附加元数据 JSON。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Message", + table: "tenant_notifications", + type: "character varying(1024)", + maxLength: 1024, + nullable: false, + comment: "通知正文。", + oldClrType: typeof(string), + oldType: "character varying(1024)", + oldMaxLength: 1024); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "tenant_notifications", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "tenant_notifications", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "tenant_notifications", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "tenant_notifications", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Channel", + table: "tenant_notifications", + type: "integer", + nullable: false, + comment: "发布通道(站内、邮件、短信等)。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "tenant_notifications", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "tenant_billing_statements", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "tenant_billing_statements", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "tenant_billing_statements", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "tenant_billing_statements", + type: "integer", + nullable: false, + comment: "当前付款状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "StatementNo", + table: "tenant_billing_statements", + type: "character varying(64)", + maxLength: 64, + nullable: false, + comment: "账单编号,供对账查询。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64); + + migrationBuilder.AlterColumn( + name: "PeriodStart", + table: "tenant_billing_statements", + type: "timestamp with time zone", + nullable: false, + comment: "账单周期开始时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "PeriodEnd", + table: "tenant_billing_statements", + type: "timestamp with time zone", + nullable: false, + comment: "账单周期结束时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "LineItemsJson", + table: "tenant_billing_statements", + type: "text", + nullable: true, + comment: "账单明细 JSON,记录各项费用。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DueDate", + table: "tenant_billing_statements", + type: "timestamp with time zone", + nullable: false, + comment: "到期日。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "tenant_billing_statements", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "tenant_billing_statements", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "tenant_billing_statements", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "tenant_billing_statements", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "AmountPaid", + table: "tenant_billing_statements", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + comment: "实付金额。", + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2); + + migrationBuilder.AlterColumn( + name: "AmountDue", + table: "tenant_billing_statements", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + comment: "应付金额。", + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2); + + migrationBuilder.AlterColumn( + name: "Id", + table: "tenant_billing_statements", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "support_tickets", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "support_tickets", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TicketNo", + table: "support_tickets", + type: "character varying(32)", + maxLength: 32, + nullable: false, + comment: "工单编号。", + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "support_tickets", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Subject", + table: "support_tickets", + type: "character varying(128)", + maxLength: 128, + nullable: false, + comment: "工单主题。", + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128); + + migrationBuilder.AlterColumn( + name: "Status", + table: "support_tickets", + type: "integer", + nullable: false, + comment: "状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "Priority", + table: "support_tickets", + type: "integer", + nullable: false, + comment: "优先级。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "OrderId", + table: "support_tickets", + type: "uuid", + nullable: true, + comment: "关联订单(如有)。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Description", + table: "support_tickets", + type: "text", + nullable: false, + comment: "工单详情。", + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "support_tickets", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "support_tickets", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CustomerUserId", + table: "support_tickets", + type: "uuid", + nullable: false, + comment: "客户用户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "support_tickets", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "support_tickets", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "ClosedAt", + table: "support_tickets", + type: "timestamp with time zone", + nullable: true, + comment: "关闭时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "AssignedAgentId", + table: "support_tickets", + type: "uuid", + nullable: true, + comment: "指派的客服。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Id", + table: "support_tickets", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "stores", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "stores", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "stores", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Tags", + table: "stores", + type: "text", + nullable: true, + comment: "门店标签(逗号分隔)。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "SupportsReservation", + table: "stores", + type: "boolean", + nullable: false, + comment: "支持预约。", + oldClrType: typeof(bool), + oldType: "boolean"); + + migrationBuilder.AlterColumn( + name: "SupportsQueueing", + table: "stores", + type: "boolean", + nullable: false, + comment: "支持排队叫号。", + oldClrType: typeof(bool), + oldType: "boolean"); + + migrationBuilder.AlterColumn( + name: "SupportsPickup", + table: "stores", + type: "boolean", + nullable: false, + comment: "是否支持自提。", + oldClrType: typeof(bool), + oldType: "boolean"); + + migrationBuilder.AlterColumn( + name: "SupportsDineIn", + table: "stores", + type: "boolean", + nullable: false, + comment: "是否支持堂食。", + oldClrType: typeof(bool), + oldType: "boolean"); + + migrationBuilder.AlterColumn( + name: "SupportsDelivery", + table: "stores", + type: "boolean", + nullable: false, + comment: "是否支持配送。", + oldClrType: typeof(bool), + oldType: "boolean"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "stores", + type: "integer", + nullable: false, + comment: "门店当前运营状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "Province", + table: "stores", + type: "character varying(64)", + maxLength: 64, + nullable: true, + comment: "所在省份。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Phone", + table: "stores", + type: "character varying(32)", + maxLength: 32, + nullable: true, + comment: "联系电话。", + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Name", + table: "stores", + type: "character varying(128)", + maxLength: 128, + nullable: false, + comment: "门店名称。", + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128); + + migrationBuilder.AlterColumn( + name: "MerchantId", + table: "stores", + type: "uuid", + nullable: false, + comment: "所属商户标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "ManagerName", + table: "stores", + type: "character varying(64)", + maxLength: 64, + nullable: true, + comment: "门店负责人姓名。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Longitude", + table: "stores", + type: "double precision", + nullable: true, + comment: "高德/腾讯地图经度。", + oldClrType: typeof(double), + oldType: "double precision", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Latitude", + table: "stores", + type: "double precision", + nullable: true, + comment: "纬度。", + oldClrType: typeof(double), + oldType: "double precision", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "District", + table: "stores", + type: "character varying(64)", + maxLength: 64, + nullable: true, + comment: "区县信息。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Description", + table: "stores", + type: "text", + nullable: true, + comment: "门店描述或公告。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeliveryRadiusKm", + table: "stores", + type: "numeric(6,2)", + precision: 6, + scale: 2, + nullable: false, + comment: "默认配送半径(公里)。", + oldClrType: typeof(decimal), + oldType: "numeric(6,2)", + oldPrecision: 6, + oldScale: 2); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "stores", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "stores", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "stores", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "stores", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "CoverImageUrl", + table: "stores", + type: "text", + nullable: true, + comment: "门店海报。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Country", + table: "stores", + type: "text", + nullable: true, + comment: "所在国家或地区。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Code", + table: "stores", + type: "character varying(32)", + maxLength: 32, + nullable: false, + comment: "门店编码,便于扫码及外部对接。", + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32); + + migrationBuilder.AlterColumn( + name: "City", + table: "stores", + type: "character varying(64)", + maxLength: 64, + nullable: true, + comment: "所在城市。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "BusinessHours", + table: "stores", + type: "character varying(256)", + maxLength: 256, + nullable: true, + comment: "门店营业时段描述(备用字符串)。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Announcement", + table: "stores", + type: "character varying(512)", + maxLength: 512, + nullable: true, + comment: "门店公告。", + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Address", + table: "stores", + type: "character varying(256)", + maxLength: 256, + nullable: true, + comment: "详细地址。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Id", + table: "stores", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "store_tables", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "store_tables", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "store_tables", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Tags", + table: "store_tables", + type: "character varying(128)", + maxLength: 128, + nullable: true, + comment: "桌台标签(堂食、快餐等)。", + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TableCode", + table: "store_tables", + type: "character varying(32)", + maxLength: 32, + nullable: false, + comment: "桌码。", + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "store_tables", + type: "uuid", + nullable: false, + comment: "门店标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "store_tables", + type: "integer", + nullable: false, + comment: "当前桌台状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "QrCodeUrl", + table: "store_tables", + type: "character varying(512)", + maxLength: 512, + nullable: true, + comment: "桌码二维码地址。", + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "store_tables", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "store_tables", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "store_tables", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "store_tables", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Capacity", + table: "store_tables", + type: "integer", + nullable: false, + comment: "可容纳人数。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "AreaId", + table: "store_tables", + type: "uuid", + nullable: true, + comment: "所在区域 ID。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Id", + table: "store_tables", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "store_table_areas", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "store_table_areas", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "store_table_areas", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "store_table_areas", + type: "uuid", + nullable: false, + comment: "门店标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "store_table_areas", + type: "character varying(64)", + maxLength: 64, + nullable: false, + comment: "区域名称。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64); + + migrationBuilder.AlterColumn( + name: "Description", + table: "store_table_areas", + type: "character varying(256)", + maxLength: 256, + nullable: true, + comment: "区域描述。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "store_table_areas", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "store_table_areas", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "store_table_areas", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "store_table_areas", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "store_table_areas", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "store_holidays", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "store_holidays", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "store_holidays", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "store_holidays", + type: "uuid", + nullable: false, + comment: "门店标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Reason", + table: "store_holidays", + type: "character varying(256)", + maxLength: 256, + nullable: true, + comment: "说明内容。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "IsClosed", + table: "store_holidays", + type: "boolean", + nullable: false, + comment: "是否全天闭店。", + oldClrType: typeof(bool), + oldType: "boolean"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "store_holidays", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "store_holidays", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Date", + table: "store_holidays", + type: "timestamp with time zone", + nullable: false, + comment: "日期。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "store_holidays", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "store_holidays", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "store_holidays", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "store_employee_shifts", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "store_employee_shifts", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "store_employee_shifts", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "store_employee_shifts", + type: "uuid", + nullable: false, + comment: "门店标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "StartTime", + table: "store_employee_shifts", + type: "interval", + nullable: false, + comment: "开始时间。", + oldClrType: typeof(TimeSpan), + oldType: "interval"); + + migrationBuilder.AlterColumn( + name: "StaffId", + table: "store_employee_shifts", + type: "uuid", + nullable: false, + comment: "员工标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "ShiftDate", + table: "store_employee_shifts", + type: "timestamp with time zone", + nullable: false, + comment: "班次日期。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "RoleType", + table: "store_employee_shifts", + type: "integer", + nullable: false, + comment: "排班角色。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "Notes", + table: "store_employee_shifts", + type: "character varying(256)", + maxLength: 256, + nullable: true, + comment: "备注。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "EndTime", + table: "store_employee_shifts", + type: "interval", + nullable: false, + comment: "结束时间。", + oldClrType: typeof(TimeSpan), + oldType: "interval"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "store_employee_shifts", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "store_employee_shifts", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "store_employee_shifts", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "store_employee_shifts", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "store_employee_shifts", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "ZoneName", + table: "store_delivery_zones", + type: "character varying(64)", + maxLength: 64, + nullable: false, + comment: "区域名称。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "store_delivery_zones", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "store_delivery_zones", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "store_delivery_zones", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "store_delivery_zones", + type: "uuid", + nullable: false, + comment: "门店标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "PolygonGeoJson", + table: "store_delivery_zones", + type: "text", + nullable: false, + comment: "GeoJSON 表示的多边形范围。", + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "MinimumOrderAmount", + table: "store_delivery_zones", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: true, + comment: "起送价。", + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "EstimatedMinutes", + table: "store_delivery_zones", + type: "integer", + nullable: true, + comment: "预计送达分钟。", + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeliveryFee", + table: "store_delivery_zones", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: true, + comment: "配送费。", + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "store_delivery_zones", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "store_delivery_zones", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "store_delivery_zones", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "store_delivery_zones", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "store_delivery_zones", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "store_business_hours", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "store_business_hours", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "store_business_hours", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "store_business_hours", + type: "uuid", + nullable: false, + comment: "门店标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "StartTime", + table: "store_business_hours", + type: "interval", + nullable: false, + comment: "开始时间(本地时间)。", + oldClrType: typeof(TimeSpan), + oldType: "interval"); + + migrationBuilder.AlterColumn( + name: "Notes", + table: "store_business_hours", + type: "character varying(256)", + maxLength: 256, + nullable: true, + comment: "备注。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "HourType", + table: "store_business_hours", + type: "integer", + nullable: false, + comment: "时段类型(正常营业、休息、预约等)。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "EndTime", + table: "store_business_hours", + type: "interval", + nullable: false, + comment: "结束时间(本地时间)。", + oldClrType: typeof(TimeSpan), + oldType: "interval"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "store_business_hours", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "store_business_hours", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DayOfWeek", + table: "store_business_hours", + type: "integer", + nullable: false, + comment: "星期几,0 表示周日。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "store_business_hours", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "store_business_hours", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "CapacityLimit", + table: "store_business_hours", + type: "integer", + nullable: true, + comment: "最大接待容量或单量限制。", + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Id", + table: "store_business_hours", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UserId", + table: "shopping_carts", + type: "uuid", + nullable: false, + comment: "用户标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "shopping_carts", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "shopping_carts", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "shopping_carts", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "TableContext", + table: "shopping_carts", + type: "character varying(64)", + maxLength: 64, + nullable: true, + comment: "桌码或场景标识(扫码点餐)。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "shopping_carts", + type: "uuid", + nullable: false, + comment: "门店标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "shopping_carts", + type: "integer", + nullable: false, + comment: "购物车状态,包含正常/锁定。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "LastModifiedAt", + table: "shopping_carts", + type: "timestamp with time zone", + nullable: false, + comment: "最近一次修改时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "DeliveryPreference", + table: "shopping_carts", + type: "character varying(32)", + maxLength: 32, + nullable: true, + comment: "履约方式(堂食/自提/配送)缓存。", + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "shopping_carts", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "shopping_carts", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "shopping_carts", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "shopping_carts", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "shopping_carts", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "reservations", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "reservations", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "reservations", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "TablePreference", + table: "reservations", + type: "character varying(64)", + maxLength: 64, + nullable: true, + comment: "桌型/标签。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "reservations", + type: "uuid", + nullable: false, + comment: "门店。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "reservations", + type: "integer", + nullable: false, + comment: "状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "ReservationTime", + table: "reservations", + type: "timestamp with time zone", + nullable: false, + comment: "预约时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "ReservationNo", + table: "reservations", + type: "character varying(32)", + maxLength: 32, + nullable: false, + comment: "预约号。", + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32); + + migrationBuilder.AlterColumn( + name: "Remark", + table: "reservations", + type: "character varying(512)", + maxLength: 512, + nullable: true, + comment: "备注。", + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "PeopleCount", + table: "reservations", + type: "integer", + nullable: false, + comment: "用餐人数。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "reservations", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "reservations", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CustomerPhone", + table: "reservations", + type: "character varying(32)", + maxLength: 32, + nullable: false, + comment: "联系电话。", + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32); + + migrationBuilder.AlterColumn( + name: "CustomerName", + table: "reservations", + type: "character varying(64)", + maxLength: 64, + nullable: false, + comment: "客户姓名。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "reservations", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "reservations", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "CheckedInAt", + table: "reservations", + type: "timestamp with time zone", + nullable: true, + comment: "实际签到时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CheckInCode", + table: "reservations", + type: "character varying(32)", + maxLength: 32, + nullable: true, + comment: "核销码/到店码。", + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CancelledAt", + table: "reservations", + type: "timestamp with time zone", + nullable: true, + comment: "取消时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Id", + table: "reservations", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "refund_requests", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "refund_requests", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "refund_requests", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "refund_requests", + type: "integer", + nullable: false, + comment: "退款状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "ReviewNotes", + table: "refund_requests", + type: "character varying(256)", + maxLength: 256, + nullable: true, + comment: "审核备注。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RequestedAt", + table: "refund_requests", + type: "timestamp with time zone", + nullable: false, + comment: "用户提交时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "RefundNo", + table: "refund_requests", + type: "character varying(32)", + maxLength: 32, + nullable: false, + comment: "退款单号。", + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32); + + migrationBuilder.AlterColumn( + name: "Reason", + table: "refund_requests", + type: "character varying(256)", + maxLength: 256, + nullable: false, + comment: "申请原因。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256); + + migrationBuilder.AlterColumn( + name: "ProcessedAt", + table: "refund_requests", + type: "timestamp with time zone", + nullable: true, + comment: "审核完成时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "OrderId", + table: "refund_requests", + type: "uuid", + nullable: false, + comment: "关联订单标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "refund_requests", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "refund_requests", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "refund_requests", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "refund_requests", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Amount", + table: "refund_requests", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + comment: "申请金额。", + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2); + + migrationBuilder.AlterColumn( + name: "Id", + table: "refund_requests", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "queue_tickets", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "queue_tickets", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TicketNumber", + table: "queue_tickets", + type: "character varying(32)", + maxLength: 32, + nullable: false, + comment: "排队编号。", + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "queue_tickets", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "queue_tickets", + type: "integer", + nullable: false, + comment: "状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "Remark", + table: "queue_tickets", + type: "character varying(256)", + maxLength: 256, + nullable: true, + comment: "备注。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "PartySize", + table: "queue_tickets", + type: "integer", + nullable: false, + comment: "就餐人数。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "ExpiredAt", + table: "queue_tickets", + type: "timestamp with time zone", + nullable: true, + comment: "过号时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "EstimatedWaitMinutes", + table: "queue_tickets", + type: "integer", + nullable: true, + comment: "预计等待分钟。", + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "queue_tickets", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "queue_tickets", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "queue_tickets", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "queue_tickets", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "CancelledAt", + table: "queue_tickets", + type: "timestamp with time zone", + nullable: true, + comment: "取消时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CalledAt", + table: "queue_tickets", + type: "timestamp with time zone", + nullable: true, + comment: "叫号时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Id", + table: "queue_tickets", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "promotion_campaigns", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "promotion_campaigns", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "promotion_campaigns", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "promotion_campaigns", + type: "integer", + nullable: false, + comment: "活动状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "StartAt", + table: "promotion_campaigns", + type: "timestamp with time zone", + nullable: false, + comment: "开始时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "RulesJson", + table: "promotion_campaigns", + type: "text", + nullable: false, + comment: "活动规则 JSON。", + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "PromotionType", + table: "promotion_campaigns", + type: "integer", + nullable: false, + comment: "活动类型。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "promotion_campaigns", + type: "character varying(128)", + maxLength: 128, + nullable: false, + comment: "活动名称。", + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128); + + migrationBuilder.AlterColumn( + name: "EndAt", + table: "promotion_campaigns", + type: "timestamp with time zone", + nullable: false, + comment: "结束时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "promotion_campaigns", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "promotion_campaigns", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "promotion_campaigns", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "promotion_campaigns", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Budget", + table: "promotion_campaigns", + type: "numeric", + nullable: true, + comment: "预算金额。", + oldClrType: typeof(decimal), + oldType: "numeric", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "BannerUrl", + table: "promotion_campaigns", + type: "character varying(512)", + maxLength: 512, + nullable: true, + comment: "营销素材(如 banner)。", + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "AudienceDescription", + table: "promotion_campaigns", + type: "character varying(512)", + maxLength: 512, + nullable: true, + comment: "目标人群描述。", + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Id", + table: "promotion_campaigns", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "products", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "products", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Unit", + table: "products", + type: "character varying(16)", + maxLength: 16, + nullable: true, + comment: "售卖单位(份/杯等)。", + oldClrType: typeof(string), + oldType: "character varying(16)", + oldMaxLength: 16, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "products", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Subtitle", + table: "products", + type: "character varying(256)", + maxLength: 256, + nullable: true, + comment: "副标题/卖点。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "products", + type: "uuid", + nullable: false, + comment: "所属门店。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "StockQuantity", + table: "products", + type: "integer", + nullable: true, + comment: "库存数量(可选)。", + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Status", + table: "products", + type: "integer", + nullable: false, + comment: "商品状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "SpuCode", + table: "products", + type: "character varying(32)", + maxLength: 32, + nullable: false, + comment: "商品编码。", + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32); + + migrationBuilder.AlterColumn( + name: "Price", + table: "products", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + comment: "现价。", + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2); + + migrationBuilder.AlterColumn( + name: "OriginalPrice", + table: "products", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: true, + comment: "原价。", + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Name", + table: "products", + type: "character varying(128)", + maxLength: 128, + nullable: false, + comment: "商品名称。", + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128); + + migrationBuilder.AlterColumn( + name: "MaxQuantityPerOrder", + table: "products", + type: "integer", + nullable: true, + comment: "最大每单限购。", + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "IsFeatured", + table: "products", + type: "boolean", + nullable: false, + comment: "是否热门推荐。", + oldClrType: typeof(bool), + oldType: "boolean"); + + migrationBuilder.AlterColumn( + name: "GalleryImages", + table: "products", + type: "character varying(1024)", + maxLength: 1024, + nullable: true, + comment: "Gallery 图片逗号分隔。", + oldClrType: typeof(string), + oldType: "character varying(1024)", + oldMaxLength: 1024, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "EnablePickup", + table: "products", + type: "boolean", + nullable: false, + comment: "支持自提。", + oldClrType: typeof(bool), + oldType: "boolean"); + + migrationBuilder.AlterColumn( + name: "EnableDineIn", + table: "products", + type: "boolean", + nullable: false, + comment: "支持堂食。", + oldClrType: typeof(bool), + oldType: "boolean"); + + migrationBuilder.AlterColumn( + name: "EnableDelivery", + table: "products", + type: "boolean", + nullable: false, + comment: "支持配送。", + oldClrType: typeof(bool), + oldType: "boolean"); + + migrationBuilder.AlterColumn( + name: "Description", + table: "products", + type: "text", + nullable: true, + comment: "商品描述。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "products", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "products", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "products", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "products", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "CoverImage", + table: "products", + type: "character varying(256)", + maxLength: 256, + nullable: true, + comment: "主图。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CategoryId", + table: "products", + type: "uuid", + nullable: false, + comment: "所属分类。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "products", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Weight", + table: "product_skus", + type: "numeric(10,3)", + precision: 10, + scale: 3, + nullable: true, + comment: "重量(千克)。", + oldClrType: typeof(decimal), + oldType: "numeric(10,3)", + oldPrecision: 10, + oldScale: 3, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "product_skus", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "product_skus", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "product_skus", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "StockQuantity", + table: "product_skus", + type: "integer", + nullable: true, + comment: "可售库存。", + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "SkuCode", + table: "product_skus", + type: "character varying(32)", + maxLength: 32, + nullable: false, + comment: "SKU 编码。", + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32); + + migrationBuilder.AlterColumn( + name: "ProductId", + table: "product_skus", + type: "uuid", + nullable: false, + comment: "所属商品标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Price", + table: "product_skus", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + comment: "售价。", + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2); + + migrationBuilder.AlterColumn( + name: "OriginalPrice", + table: "product_skus", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: true, + comment: "原价。", + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "product_skus", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "product_skus", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "product_skus", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "product_skus", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Barcode", + table: "product_skus", + type: "character varying(64)", + maxLength: 64, + nullable: true, + comment: "条形码。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "AttributesJson", + table: "product_skus", + type: "text", + nullable: false, + comment: "规格属性 JSON(记录选项 ID)。", + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "product_skus", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "WeekdaysJson", + table: "product_pricing_rules", + type: "text", + nullable: true, + comment: "生效星期(JSON 数组)。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "product_pricing_rules", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "product_pricing_rules", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "product_pricing_rules", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "StartTime", + table: "product_pricing_rules", + type: "timestamp with time zone", + nullable: true, + comment: "生效开始时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RuleType", + table: "product_pricing_rules", + type: "integer", + nullable: false, + comment: "策略类型。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "ProductId", + table: "product_pricing_rules", + type: "uuid", + nullable: false, + comment: "所属商品。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Price", + table: "product_pricing_rules", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + comment: "特殊价格。", + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2); + + migrationBuilder.AlterColumn( + name: "EndTime", + table: "product_pricing_rules", + type: "timestamp with time zone", + nullable: true, + comment: "生效结束时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "product_pricing_rules", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "product_pricing_rules", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "product_pricing_rules", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "product_pricing_rules", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "ConditionsJson", + table: "product_pricing_rules", + type: "text", + nullable: false, + comment: "条件描述(JSON),如会员等级、渠道等。", + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "product_pricing_rules", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Url", + table: "product_media_assets", + type: "character varying(512)", + maxLength: 512, + nullable: false, + comment: "媒资链接。", + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "product_media_assets", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "product_media_assets", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "product_media_assets", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "SortOrder", + table: "product_media_assets", + type: "integer", + nullable: false, + comment: "排序。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "ProductId", + table: "product_media_assets", + type: "uuid", + nullable: false, + comment: "商品标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "MediaType", + table: "product_media_assets", + type: "integer", + nullable: false, + comment: "媒体类型。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "product_media_assets", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "product_media_assets", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "product_media_assets", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "product_media_assets", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Caption", + table: "product_media_assets", + type: "character varying(256)", + maxLength: 256, + nullable: true, + comment: "描述或标题。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Id", + table: "product_media_assets", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "product_categories", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "product_categories", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "product_categories", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "product_categories", + type: "uuid", + nullable: false, + comment: "所属门店。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "SortOrder", + table: "product_categories", + type: "integer", + nullable: false, + comment: "排序值。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "product_categories", + type: "character varying(64)", + maxLength: 64, + nullable: false, + comment: "分类名称。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64); + + migrationBuilder.AlterColumn( + name: "IsEnabled", + table: "product_categories", + type: "boolean", + nullable: false, + comment: "是否启用。", + oldClrType: typeof(bool), + oldType: "boolean"); + + migrationBuilder.AlterColumn( + name: "Description", + table: "product_categories", + type: "character varying(256)", + maxLength: 256, + nullable: true, + comment: "分类描述。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "product_categories", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "product_categories", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "product_categories", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "product_categories", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "product_categories", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "product_attribute_options", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "product_attribute_options", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "product_attribute_options", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "SortOrder", + table: "product_attribute_options", + type: "integer", + nullable: false, + comment: "排序。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "product_attribute_options", + type: "character varying(64)", + maxLength: 64, + nullable: false, + comment: "选项名称。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64); + + migrationBuilder.AlterColumn( + name: "IsDefault", + table: "product_attribute_options", + type: "boolean", + nullable: false, + comment: "是否默认选中。", + oldClrType: typeof(bool), + oldType: "boolean"); + + migrationBuilder.AlterColumn( + name: "ExtraPrice", + table: "product_attribute_options", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: true, + comment: "附加价格。", + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "product_attribute_options", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "product_attribute_options", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "product_attribute_options", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "product_attribute_options", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "AttributeGroupId", + table: "product_attribute_options", + type: "uuid", + nullable: false, + comment: "所属规格组。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "product_attribute_options", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "product_attribute_groups", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "product_attribute_groups", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "product_attribute_groups", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "product_attribute_groups", + type: "uuid", + nullable: true, + comment: "关联门店,可为空表示所有门店共享。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "SortOrder", + table: "product_attribute_groups", + type: "integer", + nullable: false, + comment: "显示排序。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "SelectionType", + table: "product_attribute_groups", + type: "integer", + nullable: false, + comment: "选择类型(单选/多选)。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "product_attribute_groups", + type: "character varying(64)", + maxLength: 64, + nullable: false, + comment: "分组名称,例如“辣度”“份量”。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64); + + migrationBuilder.AlterColumn( + name: "IsRequired", + table: "product_attribute_groups", + type: "boolean", + nullable: false, + comment: "是否必选。", + oldClrType: typeof(bool), + oldType: "boolean"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "product_attribute_groups", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "product_attribute_groups", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "product_attribute_groups", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "product_attribute_groups", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "product_attribute_groups", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "product_addon_options", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "product_addon_options", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "product_addon_options", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "SortOrder", + table: "product_addon_options", + type: "integer", + nullable: false, + comment: "排序。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "product_addon_options", + type: "character varying(64)", + maxLength: 64, + nullable: false, + comment: "选项名称。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64); + + migrationBuilder.AlterColumn( + name: "IsDefault", + table: "product_addon_options", + type: "boolean", + nullable: false, + comment: "是否默认选项。", + oldClrType: typeof(bool), + oldType: "boolean"); + + migrationBuilder.AlterColumn( + name: "ExtraPrice", + table: "product_addon_options", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: true, + comment: "附加价格。", + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "product_addon_options", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "product_addon_options", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "product_addon_options", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "product_addon_options", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "AddonGroupId", + table: "product_addon_options", + type: "uuid", + nullable: false, + comment: "所属加料分组。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "product_addon_options", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "product_addon_groups", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "product_addon_groups", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "product_addon_groups", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "SortOrder", + table: "product_addon_groups", + type: "integer", + nullable: false, + comment: "排序值。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "SelectionType", + table: "product_addon_groups", + type: "integer", + nullable: false, + comment: "选择类型。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "ProductId", + table: "product_addon_groups", + type: "uuid", + nullable: false, + comment: "所属商品。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "product_addon_groups", + type: "character varying(64)", + maxLength: 64, + nullable: false, + comment: "分组名称。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64); + + migrationBuilder.AlterColumn( + name: "MinSelect", + table: "product_addon_groups", + type: "integer", + nullable: true, + comment: "最小选择数量。", + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "MaxSelect", + table: "product_addon_groups", + type: "integer", + nullable: true, + comment: "最大选择数量。", + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "IsRequired", + table: "product_addon_groups", + type: "boolean", + nullable: false, + comment: "是否必选。", + oldClrType: typeof(bool), + oldType: "boolean"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "product_addon_groups", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "product_addon_groups", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "product_addon_groups", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "product_addon_groups", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "product_addon_groups", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "payment_refund_records", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "payment_refund_records", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "payment_refund_records", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "payment_refund_records", + type: "integer", + nullable: false, + comment: "退款状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "RequestedAt", + table: "payment_refund_records", + type: "timestamp with time zone", + nullable: false, + comment: "退款请求时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "PaymentRecordId", + table: "payment_refund_records", + type: "uuid", + nullable: false, + comment: "原支付记录标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Payload", + table: "payment_refund_records", + type: "text", + nullable: true, + comment: "渠道返回的原始数据 JSON。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "OrderId", + table: "payment_refund_records", + type: "uuid", + nullable: false, + comment: "关联订单标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "payment_refund_records", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "payment_refund_records", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "payment_refund_records", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "payment_refund_records", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "CompletedAt", + table: "payment_refund_records", + type: "timestamp with time zone", + nullable: true, + comment: "完成时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ChannelRefundId", + table: "payment_refund_records", + type: "character varying(64)", + maxLength: 64, + nullable: true, + comment: "渠道退款流水号。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Amount", + table: "payment_refund_records", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + comment: "退款金额。", + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2); + + migrationBuilder.AlterColumn( + name: "Id", + table: "payment_refund_records", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "payment_records", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "payment_records", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TradeNo", + table: "payment_records", + type: "character varying(64)", + maxLength: 64, + nullable: true, + comment: "平台交易号。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "payment_records", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "payment_records", + type: "integer", + nullable: false, + comment: "支付状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "Remark", + table: "payment_records", + type: "character varying(256)", + maxLength: 256, + nullable: true, + comment: "错误/备注。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Payload", + table: "payment_records", + type: "text", + nullable: true, + comment: "原始回调内容。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "PaidAt", + table: "payment_records", + type: "timestamp with time zone", + nullable: true, + comment: "支付完成时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "OrderId", + table: "payment_records", + type: "uuid", + nullable: false, + comment: "关联订单。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Method", + table: "payment_records", + type: "integer", + nullable: false, + comment: "支付方式。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "payment_records", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "payment_records", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "payment_records", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "payment_records", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "ChannelTransactionId", + table: "payment_records", + type: "character varying(64)", + maxLength: 64, + nullable: true, + comment: "第三方渠道单号。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Amount", + table: "payment_records", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + comment: "支付金额。", + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2); + + migrationBuilder.AlterColumn( + name: "Id", + table: "payment_records", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "orders", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "orders", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "orders", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "TableNo", + table: "orders", + type: "character varying(32)", + maxLength: 32, + nullable: true, + comment: "就餐桌号。", + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "orders", + type: "uuid", + nullable: false, + comment: "门店。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "orders", + type: "integer", + nullable: false, + comment: "当前状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "ReservationId", + table: "orders", + type: "uuid", + nullable: true, + comment: "预约 ID。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Remark", + table: "orders", + type: "character varying(512)", + maxLength: 512, + nullable: true, + comment: "备注。", + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "QueueNumber", + table: "orders", + type: "character varying(32)", + maxLength: 32, + nullable: true, + comment: "排队号(如有)。", + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "PaymentStatus", + table: "orders", + type: "integer", + nullable: false, + comment: "支付状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "PayableAmount", + table: "orders", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + comment: "应付金额。", + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2); + + migrationBuilder.AlterColumn( + name: "PaidAt", + table: "orders", + type: "timestamp with time zone", + nullable: true, + comment: "支付时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "PaidAmount", + table: "orders", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + comment: "实付金额。", + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2); + + migrationBuilder.AlterColumn( + name: "OrderNo", + table: "orders", + type: "character varying(32)", + maxLength: 32, + nullable: false, + comment: "订单号。", + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32); + + migrationBuilder.AlterColumn( + name: "ItemsAmount", + table: "orders", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + comment: "商品总额。", + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2); + + migrationBuilder.AlterColumn( + name: "FinishedAt", + table: "orders", + type: "timestamp with time zone", + nullable: true, + comment: "完成时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DiscountAmount", + table: "orders", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + comment: "优惠金额。", + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2); + + migrationBuilder.AlterColumn( + name: "DeliveryType", + table: "orders", + type: "integer", + nullable: false, + comment: "履约类型。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "orders", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "orders", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CustomerPhone", + table: "orders", + type: "character varying(32)", + maxLength: 32, + nullable: true, + comment: "顾客手机号。", + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CustomerName", + table: "orders", + type: "character varying(64)", + maxLength: 64, + nullable: true, + comment: "顾客姓名。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "orders", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "orders", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Channel", + table: "orders", + type: "integer", + nullable: false, + comment: "下单渠道。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "CancelledAt", + table: "orders", + type: "timestamp with time zone", + nullable: true, + comment: "取消时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CancelReason", + table: "orders", + type: "character varying(256)", + maxLength: 256, + nullable: true, + comment: "取消原因。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Id", + table: "orders", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "order_status_histories", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "order_status_histories", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "order_status_histories", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "order_status_histories", + type: "integer", + nullable: false, + comment: "变更后的状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "OrderId", + table: "order_status_histories", + type: "uuid", + nullable: false, + comment: "订单标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "OperatorId", + table: "order_status_histories", + type: "uuid", + nullable: true, + comment: "操作人标识(可为空表示系统)。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "OccurredAt", + table: "order_status_histories", + type: "timestamp with time zone", + nullable: false, + comment: "发生时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Notes", + table: "order_status_histories", + type: "character varying(256)", + maxLength: 256, + nullable: true, + comment: "备注信息。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "order_status_histories", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "order_status_histories", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "order_status_histories", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "order_status_histories", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "order_status_histories", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "order_items", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "order_items", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UnitPrice", + table: "order_items", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + comment: "单价。", + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2); + + migrationBuilder.AlterColumn( + name: "Unit", + table: "order_items", + type: "character varying(16)", + maxLength: 16, + nullable: true, + comment: "单位。", + oldClrType: typeof(string), + oldType: "character varying(16)", + oldMaxLength: 16, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "order_items", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "SubTotal", + table: "order_items", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + comment: "小计。", + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2); + + migrationBuilder.AlterColumn( + name: "SkuName", + table: "order_items", + type: "character varying(128)", + maxLength: 128, + nullable: true, + comment: "SKU/规格描述。", + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Quantity", + table: "order_items", + type: "integer", + nullable: false, + comment: "数量。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "ProductName", + table: "order_items", + type: "character varying(128)", + maxLength: 128, + nullable: false, + comment: "商品名称。", + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128); + + migrationBuilder.AlterColumn( + name: "ProductId", + table: "order_items", + type: "uuid", + nullable: false, + comment: "商品 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "OrderId", + table: "order_items", + type: "uuid", + nullable: false, + comment: "订单 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "DiscountAmount", + table: "order_items", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + comment: "折扣金额。", + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "order_items", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "order_items", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "order_items", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "order_items", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "AttributesJson", + table: "order_items", + type: "text", + nullable: true, + comment: "自定义属性 JSON。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Id", + table: "order_items", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UserId", + table: "navigation_requests", + type: "uuid", + nullable: false, + comment: "用户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "navigation_requests", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "navigation_requests", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "navigation_requests", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "TargetApp", + table: "navigation_requests", + type: "integer", + nullable: false, + comment: "跳转的地图应用。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "navigation_requests", + type: "uuid", + nullable: false, + comment: "门店 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "RequestedAt", + table: "navigation_requests", + type: "timestamp with time zone", + nullable: false, + comment: "请求时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "navigation_requests", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "navigation_requests", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "navigation_requests", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "navigation_requests", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Channel", + table: "navigation_requests", + type: "integer", + nullable: false, + comment: "来源通道(小程序、H5 等)。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "navigation_requests", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "WindowStart", + table: "metric_snapshots", + type: "timestamp with time zone", + nullable: false, + comment: "统计时间窗口开始。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "WindowEnd", + table: "metric_snapshots", + type: "timestamp with time zone", + nullable: false, + comment: "统计时间窗口结束。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Value", + table: "metric_snapshots", + type: "numeric(18,4)", + precision: 18, + scale: 4, + nullable: false, + comment: "数值。", + oldClrType: typeof(decimal), + oldType: "numeric(18,4)", + oldPrecision: 18, + oldScale: 4); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "metric_snapshots", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "metric_snapshots", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "metric_snapshots", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "MetricDefinitionId", + table: "metric_snapshots", + type: "uuid", + nullable: false, + comment: "指标定义 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "DimensionKey", + table: "metric_snapshots", + type: "character varying(256)", + maxLength: 256, + nullable: false, + comment: "维度键(JSON)。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "metric_snapshots", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "metric_snapshots", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "metric_snapshots", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "metric_snapshots", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "metric_snapshots", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "metric_definitions", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "metric_definitions", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "metric_definitions", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "metric_definitions", + type: "character varying(128)", + maxLength: 128, + nullable: false, + comment: "指标名称。", + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128); + + migrationBuilder.AlterColumn( + name: "DimensionsJson", + table: "metric_definitions", + type: "text", + nullable: true, + comment: "维度描述 JSON。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Description", + table: "metric_definitions", + type: "character varying(512)", + maxLength: 512, + nullable: true, + comment: "说明。", + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "metric_definitions", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "metric_definitions", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DefaultAggregation", + table: "metric_definitions", + type: "character varying(32)", + maxLength: 32, + nullable: false, + comment: "默认聚合方式。", + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "metric_definitions", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "metric_definitions", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Code", + table: "metric_definitions", + type: "character varying(64)", + maxLength: 64, + nullable: false, + comment: "指标编码。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64); + + migrationBuilder.AlterColumn( + name: "Id", + table: "metric_definitions", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "metric_alert_rules", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "metric_alert_rules", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "metric_alert_rules", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Severity", + table: "metric_alert_rules", + type: "integer", + nullable: false, + comment: "告警级别。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "NotificationChannels", + table: "metric_alert_rules", + type: "character varying(256)", + maxLength: 256, + nullable: false, + comment: "通知渠道。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256); + + migrationBuilder.AlterColumn( + name: "MetricDefinitionId", + table: "metric_alert_rules", + type: "uuid", + nullable: false, + comment: "关联指标。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Enabled", + table: "metric_alert_rules", + type: "boolean", + nullable: false, + comment: "是否启用。", + oldClrType: typeof(bool), + oldType: "boolean"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "metric_alert_rules", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "metric_alert_rules", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "metric_alert_rules", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "metric_alert_rules", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "ConditionJson", + table: "metric_alert_rules", + type: "text", + nullable: false, + comment: "触发条件 JSON。", + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "metric_alert_rules", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "merchants", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "merchants", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "merchants", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "TaxNumber", + table: "merchants", + type: "text", + nullable: true, + comment: "税号/统一社会信用代码。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "SupportEmail", + table: "merchants", + type: "text", + nullable: true, + comment: "客服邮箱。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Status", + table: "merchants", + type: "integer", + nullable: false, + comment: "入驻状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "ServicePhone", + table: "merchants", + type: "text", + nullable: true, + comment: "客服电话。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ReviewRemarks", + table: "merchants", + type: "character varying(512)", + maxLength: 512, + nullable: true, + comment: "审核备注或驳回原因。", + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Province", + table: "merchants", + type: "character varying(64)", + maxLength: 64, + nullable: true, + comment: "所在省份。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Longitude", + table: "merchants", + type: "double precision", + nullable: true, + comment: "经度信息。", + oldClrType: typeof(double), + oldType: "double precision", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "LogoUrl", + table: "merchants", + type: "text", + nullable: true, + comment: "品牌 Logo。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "LegalPerson", + table: "merchants", + type: "character varying(64)", + maxLength: 64, + nullable: true, + comment: "法人或负责人姓名。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Latitude", + table: "merchants", + type: "double precision", + nullable: true, + comment: "纬度信息。", + oldClrType: typeof(double), + oldType: "double precision", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "LastReviewedAt", + table: "merchants", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次审核时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "JoinedAt", + table: "merchants", + type: "timestamp with time zone", + nullable: true, + comment: "入驻时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "District", + table: "merchants", + type: "character varying(64)", + maxLength: 64, + nullable: true, + comment: "所在区县。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "merchants", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "merchants", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "merchants", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "merchants", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "ContactPhone", + table: "merchants", + type: "character varying(32)", + maxLength: 32, + nullable: false, + comment: "联系电话。", + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32); + + migrationBuilder.AlterColumn( + name: "ContactEmail", + table: "merchants", + type: "character varying(128)", + maxLength: 128, + nullable: true, + comment: "联系邮箱。", + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "City", + table: "merchants", + type: "character varying(64)", + maxLength: 64, + nullable: true, + comment: "所在城市。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Category", + table: "merchants", + type: "text", + nullable: true, + comment: "品牌所属品类,如火锅、咖啡等。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "BusinessLicenseNumber", + table: "merchants", + type: "character varying(64)", + maxLength: 64, + nullable: true, + comment: "营业执照号。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "BusinessLicenseImageUrl", + table: "merchants", + type: "text", + nullable: true, + comment: "营业执照扫描件地址。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "BrandName", + table: "merchants", + type: "character varying(128)", + maxLength: 128, + nullable: false, + comment: "品牌名称(对外展示)。", + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128); + + migrationBuilder.AlterColumn( + name: "BrandAlias", + table: "merchants", + type: "character varying(64)", + maxLength: 64, + nullable: true, + comment: "品牌简称或别名。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Address", + table: "merchants", + type: "character varying(256)", + maxLength: 256, + nullable: true, + comment: "详细地址。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Id", + table: "merchants", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "merchant_staff", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "merchant_staff", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "merchant_staff", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "merchant_staff", + type: "uuid", + nullable: true, + comment: "可选的关联门店 ID。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Status", + table: "merchant_staff", + type: "integer", + nullable: false, + comment: "员工状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "RoleType", + table: "merchant_staff", + type: "integer", + nullable: false, + comment: "员工角色类型。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "Phone", + table: "merchant_staff", + type: "character varying(32)", + maxLength: 32, + nullable: false, + comment: "手机号。", + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32); + + migrationBuilder.AlterColumn( + name: "PermissionsJson", + table: "merchant_staff", + type: "text", + nullable: true, + comment: "自定义权限(JSON)。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Name", + table: "merchant_staff", + type: "character varying(64)", + maxLength: 64, + nullable: false, + comment: "员工姓名。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64); + + migrationBuilder.AlterColumn( + name: "MerchantId", + table: "merchant_staff", + type: "uuid", + nullable: false, + comment: "所属商户标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "IdentityUserId", + table: "merchant_staff", + type: "uuid", + nullable: true, + comment: "登录账号 ID(指向统一身份体系)。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Email", + table: "merchant_staff", + type: "character varying(128)", + maxLength: 128, + nullable: true, + comment: "邮箱地址。", + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "merchant_staff", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "merchant_staff", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "merchant_staff", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "merchant_staff", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "merchant_staff", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "merchant_documents", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "merchant_documents", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "merchant_documents", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "merchant_documents", + type: "integer", + nullable: false, + comment: "审核状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "Remarks", + table: "merchant_documents", + type: "text", + nullable: true, + comment: "审核备注或驳回原因。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "MerchantId", + table: "merchant_documents", + type: "uuid", + nullable: false, + comment: "所属商户标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "IssuedAt", + table: "merchant_documents", + type: "timestamp with time zone", + nullable: true, + comment: "签发日期。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FileUrl", + table: "merchant_documents", + type: "character varying(512)", + maxLength: 512, + nullable: false, + comment: "证照文件链接。", + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512); + + migrationBuilder.AlterColumn( + name: "ExpiresAt", + table: "merchant_documents", + type: "timestamp with time zone", + nullable: true, + comment: "到期日期。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DocumentType", + table: "merchant_documents", + type: "integer", + nullable: false, + comment: "证照类型。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "DocumentNumber", + table: "merchant_documents", + type: "character varying(64)", + maxLength: 64, + nullable: true, + comment: "证照编号。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "merchant_documents", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "merchant_documents", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "merchant_documents", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "merchant_documents", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "merchant_documents", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "merchant_contracts", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "merchant_contracts", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TerminationReason", + table: "merchant_contracts", + type: "character varying(256)", + maxLength: 256, + nullable: true, + comment: "终止原因。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TerminatedAt", + table: "merchant_contracts", + type: "timestamp with time zone", + nullable: true, + comment: "终止时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "merchant_contracts", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "merchant_contracts", + type: "integer", + nullable: false, + comment: "合同状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "StartDate", + table: "merchant_contracts", + type: "timestamp with time zone", + nullable: false, + comment: "合同开始时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "SignedAt", + table: "merchant_contracts", + type: "timestamp with time zone", + nullable: true, + comment: "签署时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "MerchantId", + table: "merchant_contracts", + type: "uuid", + nullable: false, + comment: "所属商户标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "FileUrl", + table: "merchant_contracts", + type: "character varying(512)", + maxLength: 512, + nullable: false, + comment: "合同文件存储地址。", + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512); + + migrationBuilder.AlterColumn( + name: "EndDate", + table: "merchant_contracts", + type: "timestamp with time zone", + nullable: false, + comment: "合同结束时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "merchant_contracts", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "merchant_contracts", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "merchant_contracts", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "merchant_contracts", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "ContractNumber", + table: "merchant_contracts", + type: "character varying(64)", + maxLength: 64, + nullable: false, + comment: "合同编号。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64); + + migrationBuilder.AlterColumn( + name: "Id", + table: "merchant_contracts", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "member_tiers", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "member_tiers", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "member_tiers", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "SortOrder", + table: "member_tiers", + type: "integer", + nullable: false, + comment: "排序值。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "RequiredGrowth", + table: "member_tiers", + type: "integer", + nullable: false, + comment: "所需成长值。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "member_tiers", + type: "character varying(64)", + maxLength: 64, + nullable: false, + comment: "等级名称。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "member_tiers", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "member_tiers", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "member_tiers", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "member_tiers", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "BenefitsJson", + table: "member_tiers", + type: "text", + nullable: false, + comment: "等级权益(JSON)。", + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "member_tiers", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UserId", + table: "member_profiles", + type: "uuid", + nullable: false, + comment: "用户标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "member_profiles", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "member_profiles", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "member_profiles", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "member_profiles", + type: "integer", + nullable: false, + comment: "会员状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "PointsBalance", + table: "member_profiles", + type: "integer", + nullable: false, + comment: "会员积分余额。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "Nickname", + table: "member_profiles", + type: "character varying(64)", + maxLength: 64, + nullable: true, + comment: "昵称。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Mobile", + table: "member_profiles", + type: "character varying(32)", + maxLength: 32, + nullable: false, + comment: "手机号。", + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32); + + migrationBuilder.AlterColumn( + name: "MemberTierId", + table: "member_profiles", + type: "uuid", + nullable: true, + comment: "当前会员等级 ID。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "JoinedAt", + table: "member_profiles", + type: "timestamp with time zone", + nullable: false, + comment: "注册时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "GrowthValue", + table: "member_profiles", + type: "integer", + nullable: false, + comment: "成长值/经验值。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "member_profiles", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "member_profiles", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "member_profiles", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "member_profiles", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "BirthDate", + table: "member_profiles", + type: "timestamp with time zone", + nullable: true, + comment: "生日。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "AvatarUrl", + table: "member_profiles", + type: "character varying(256)", + maxLength: 256, + nullable: true, + comment: "头像。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Id", + table: "member_profiles", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "member_point_ledgers", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "member_point_ledgers", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "member_point_ledgers", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "SourceId", + table: "member_point_ledgers", + type: "uuid", + nullable: true, + comment: "来源 ID(订单、活动等)。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Reason", + table: "member_point_ledgers", + type: "integer", + nullable: false, + comment: "变动原因。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "OccurredAt", + table: "member_point_ledgers", + type: "timestamp with time zone", + nullable: false, + comment: "发生时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "MemberId", + table: "member_point_ledgers", + type: "uuid", + nullable: false, + comment: "会员标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "ExpireAt", + table: "member_point_ledgers", + type: "timestamp with time zone", + nullable: true, + comment: "过期时间(如适用)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "member_point_ledgers", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "member_point_ledgers", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "member_point_ledgers", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "member_point_ledgers", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "ChangeAmount", + table: "member_point_ledgers", + type: "integer", + nullable: false, + comment: "变动数量,可为负值。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "BalanceAfterChange", + table: "member_point_ledgers", + type: "integer", + nullable: false, + comment: "变动后余额。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "member_point_ledgers", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "member_growth_logs", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "member_growth_logs", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "member_growth_logs", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "OccurredAt", + table: "member_growth_logs", + type: "timestamp with time zone", + nullable: false, + comment: "发生时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Notes", + table: "member_growth_logs", + type: "character varying(256)", + maxLength: 256, + nullable: true, + comment: "备注。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "MemberId", + table: "member_growth_logs", + type: "uuid", + nullable: false, + comment: "会员标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "member_growth_logs", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "member_growth_logs", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CurrentValue", + table: "member_growth_logs", + type: "integer", + nullable: false, + comment: "当前成长值。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "member_growth_logs", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "member_growth_logs", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "ChangeValue", + table: "member_growth_logs", + type: "integer", + nullable: false, + comment: "变动数量。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "member_growth_logs", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "map_locations", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "map_locations", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "map_locations", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "map_locations", + type: "uuid", + nullable: true, + comment: "关联门店 ID,可空表示独立 POI。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Name", + table: "map_locations", + type: "character varying(128)", + maxLength: 128, + nullable: false, + comment: "名称。", + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128); + + migrationBuilder.AlterColumn( + name: "Longitude", + table: "map_locations", + type: "double precision", + nullable: false, + comment: "经度。", + oldClrType: typeof(double), + oldType: "double precision"); + + migrationBuilder.AlterColumn( + name: "Latitude", + table: "map_locations", + type: "double precision", + nullable: false, + comment: "纬度。", + oldClrType: typeof(double), + oldType: "double precision"); + + migrationBuilder.AlterColumn( + name: "Landmark", + table: "map_locations", + type: "character varying(128)", + maxLength: 128, + nullable: true, + comment: "打车/导航落点描述。", + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "map_locations", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "map_locations", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "map_locations", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "map_locations", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Address", + table: "map_locations", + type: "character varying(256)", + maxLength: 256, + nullable: false, + comment: "地址。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256); + + migrationBuilder.AlterColumn( + name: "Id", + table: "map_locations", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "inventory_items", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "inventory_items", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "inventory_items", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "inventory_items", + type: "uuid", + nullable: false, + comment: "门店标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "SafetyStock", + table: "inventory_items", + type: "integer", + nullable: true, + comment: "安全库存阈值。", + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "QuantityReserved", + table: "inventory_items", + type: "integer", + nullable: false, + comment: "已锁定库存(订单占用)。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "QuantityOnHand", + table: "inventory_items", + type: "integer", + nullable: false, + comment: "可用库存。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "ProductSkuId", + table: "inventory_items", + type: "uuid", + nullable: false, + comment: "SKU 标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Location", + table: "inventory_items", + type: "character varying(64)", + maxLength: 64, + nullable: true, + comment: "储位或仓位信息。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ExpireDate", + table: "inventory_items", + type: "timestamp with time zone", + nullable: true, + comment: "过期日期。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "inventory_items", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "inventory_items", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "inventory_items", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "inventory_items", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "BatchNumber", + table: "inventory_items", + type: "character varying(64)", + maxLength: 64, + nullable: true, + comment: "批次编号,可为空表示混批。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Id", + table: "inventory_items", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "inventory_batches", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "inventory_batches", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "inventory_batches", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "inventory_batches", + type: "uuid", + nullable: false, + comment: "门店标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "RemainingQuantity", + table: "inventory_batches", + type: "integer", + nullable: false, + comment: "剩余数量。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "Quantity", + table: "inventory_batches", + type: "integer", + nullable: false, + comment: "入库数量。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "ProductionDate", + table: "inventory_batches", + type: "timestamp with time zone", + nullable: true, + comment: "生产日期。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ProductSkuId", + table: "inventory_batches", + type: "uuid", + nullable: false, + comment: "SKU 标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "ExpireDate", + table: "inventory_batches", + type: "timestamp with time zone", + nullable: true, + comment: "过期日期。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "inventory_batches", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "inventory_batches", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "inventory_batches", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "inventory_batches", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "BatchNumber", + table: "inventory_batches", + type: "character varying(64)", + maxLength: 64, + nullable: false, + comment: "批次编号。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64); + + migrationBuilder.AlterColumn( + name: "Id", + table: "inventory_batches", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "inventory_adjustments", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "inventory_adjustments", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "inventory_adjustments", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Reason", + table: "inventory_adjustments", + type: "character varying(256)", + maxLength: 256, + nullable: true, + comment: "原因说明。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Quantity", + table: "inventory_adjustments", + type: "integer", + nullable: false, + comment: "调整数量,正数增加,负数减少。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "OperatorId", + table: "inventory_adjustments", + type: "uuid", + nullable: true, + comment: "操作人标识。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "OccurredAt", + table: "inventory_adjustments", + type: "timestamp with time zone", + nullable: false, + comment: "发生时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "InventoryItemId", + table: "inventory_adjustments", + type: "uuid", + nullable: false, + comment: "对应的库存记录标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "inventory_adjustments", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "inventory_adjustments", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "inventory_adjustments", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "inventory_adjustments", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "AdjustmentType", + table: "inventory_adjustments", + type: "integer", + nullable: false, + comment: "调整类型。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "inventory_adjustments", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UserId", + table: "group_participants", + type: "uuid", + nullable: false, + comment: "用户标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "group_participants", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "group_participants", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "group_participants", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "group_participants", + type: "integer", + nullable: false, + comment: "参与状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "OrderId", + table: "group_participants", + type: "uuid", + nullable: false, + comment: "对应订单标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "JoinedAt", + table: "group_participants", + type: "timestamp with time zone", + nullable: false, + comment: "参与时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "GroupOrderId", + table: "group_participants", + type: "uuid", + nullable: false, + comment: "拼单活动标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "group_participants", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "group_participants", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "group_participants", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "group_participants", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "group_participants", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "group_orders", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "group_orders", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "group_orders", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "TargetCount", + table: "group_orders", + type: "integer", + nullable: false, + comment: "成团需要的人数。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "SucceededAt", + table: "group_orders", + type: "timestamp with time zone", + nullable: true, + comment: "成团时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "group_orders", + type: "uuid", + nullable: false, + comment: "门店标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "group_orders", + type: "integer", + nullable: false, + comment: "拼团状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "StartAt", + table: "group_orders", + type: "timestamp with time zone", + nullable: false, + comment: "开始时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "ProductId", + table: "group_orders", + type: "uuid", + nullable: false, + comment: "关联商品或套餐。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "LeaderUserId", + table: "group_orders", + type: "uuid", + nullable: false, + comment: "团长用户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "GroupPrice", + table: "group_orders", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + comment: "拼团价格。", + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2); + + migrationBuilder.AlterColumn( + name: "GroupOrderNo", + table: "group_orders", + type: "character varying(32)", + maxLength: 32, + nullable: false, + comment: "拼单编号。", + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32); + + migrationBuilder.AlterColumn( + name: "EndAt", + table: "group_orders", + type: "timestamp with time zone", + nullable: false, + comment: "结束时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "group_orders", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "group_orders", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CurrentCount", + table: "group_orders", + type: "integer", + nullable: false, + comment: "当前已参与人数。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "group_orders", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "group_orders", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "CancelledAt", + table: "group_orders", + type: "timestamp with time zone", + nullable: true, + comment: "取消时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Id", + table: "group_orders", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "delivery_orders", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "delivery_orders", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "delivery_orders", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "delivery_orders", + type: "integer", + nullable: false, + comment: "状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "ProviderOrderId", + table: "delivery_orders", + type: "character varying(64)", + maxLength: 64, + nullable: true, + comment: "第三方配送单号。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Provider", + table: "delivery_orders", + type: "integer", + nullable: false, + comment: "配送服务商。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "PickedUpAt", + table: "delivery_orders", + type: "timestamp with time zone", + nullable: true, + comment: "取餐时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FailureReason", + table: "delivery_orders", + type: "character varying(256)", + maxLength: 256, + nullable: true, + comment: "异常原因。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DispatchedAt", + table: "delivery_orders", + type: "timestamp with time zone", + nullable: true, + comment: "下发时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeliveryFee", + table: "delivery_orders", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: true, + comment: "配送费。", + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeliveredAt", + table: "delivery_orders", + type: "timestamp with time zone", + nullable: true, + comment: "完成时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "delivery_orders", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "delivery_orders", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "delivery_orders", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "delivery_orders", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "CourierPhone", + table: "delivery_orders", + type: "character varying(32)", + maxLength: 32, + nullable: true, + comment: "骑手电话。", + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CourierName", + table: "delivery_orders", + type: "character varying(64)", + maxLength: 64, + nullable: true, + comment: "骑手姓名。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Id", + table: "delivery_orders", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "delivery_events", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "delivery_events", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "delivery_events", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Payload", + table: "delivery_events", + type: "text", + nullable: true, + comment: "原始数据 JSON。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "OccurredAt", + table: "delivery_events", + type: "timestamp with time zone", + nullable: false, + comment: "发生时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Message", + table: "delivery_events", + type: "character varying(256)", + maxLength: 256, + nullable: false, + comment: "事件描述。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256); + + migrationBuilder.AlterColumn( + name: "EventType", + table: "delivery_events", + type: "integer", + nullable: false, + comment: "事件类型。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "DeliveryOrderId", + table: "delivery_events", + type: "uuid", + nullable: false, + comment: "配送单标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "delivery_events", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "delivery_events", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "delivery_events", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "delivery_events", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "delivery_events", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UserId", + table: "coupons", + type: "uuid", + nullable: false, + comment: "归属用户。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UsedAt", + table: "coupons", + type: "timestamp with time zone", + nullable: true, + comment: "使用时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "coupons", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "coupons", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "coupons", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "coupons", + type: "integer", + nullable: false, + comment: "状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "OrderId", + table: "coupons", + type: "uuid", + nullable: true, + comment: "订单 ID(已使用时记录)。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "IssuedAt", + table: "coupons", + type: "timestamp with time zone", + nullable: false, + comment: "发放时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "ExpireAt", + table: "coupons", + type: "timestamp with time zone", + nullable: false, + comment: "到期时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "coupons", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "coupons", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "coupons", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "coupons", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "CouponTemplateId", + table: "coupons", + type: "uuid", + nullable: false, + comment: "模板标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Code", + table: "coupons", + type: "character varying(32)", + maxLength: 32, + nullable: false, + comment: "券码或序列号。", + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32); + + migrationBuilder.AlterColumn( + name: "Id", + table: "coupons", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Value", + table: "coupon_templates", + type: "numeric", + nullable: false, + comment: "面值或折扣额度。", + oldClrType: typeof(decimal), + oldType: "numeric"); + + migrationBuilder.AlterColumn( + name: "ValidTo", + table: "coupon_templates", + type: "timestamp with time zone", + nullable: true, + comment: "可用结束时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ValidFrom", + table: "coupon_templates", + type: "timestamp with time zone", + nullable: true, + comment: "可用开始时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "coupon_templates", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "coupon_templates", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TotalQuantity", + table: "coupon_templates", + type: "integer", + nullable: true, + comment: "总发放数量上限。", + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "coupon_templates", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "StoreScopeJson", + table: "coupon_templates", + type: "text", + nullable: true, + comment: "适用门店 ID 集合(JSON)。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Status", + table: "coupon_templates", + type: "integer", + nullable: false, + comment: "状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "RelativeValidDays", + table: "coupon_templates", + type: "integer", + nullable: true, + comment: "有效天数(相对发放时间)。", + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ProductScopeJson", + table: "coupon_templates", + type: "text", + nullable: true, + comment: "适用品类或商品范围(JSON)。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Name", + table: "coupon_templates", + type: "character varying(128)", + maxLength: 128, + nullable: false, + comment: "模板名称。", + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128); + + migrationBuilder.AlterColumn( + name: "MinimumSpend", + table: "coupon_templates", + type: "numeric", + nullable: true, + comment: "最低消费门槛。", + oldClrType: typeof(decimal), + oldType: "numeric", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DiscountCap", + table: "coupon_templates", + type: "numeric", + nullable: true, + comment: "折扣上限(针对折扣券)。", + oldClrType: typeof(decimal), + oldType: "numeric", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Description", + table: "coupon_templates", + type: "character varying(512)", + maxLength: 512, + nullable: true, + comment: "备注。", + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "coupon_templates", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "coupon_templates", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "coupon_templates", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "coupon_templates", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "CouponType", + table: "coupon_templates", + type: "integer", + nullable: false, + comment: "券类型。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "ClaimedQuantity", + table: "coupon_templates", + type: "integer", + nullable: false, + comment: "已领取数量。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "ChannelsJson", + table: "coupon_templates", + type: "text", + nullable: true, + comment: "发放渠道(JSON)。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "AllowStack", + table: "coupon_templates", + type: "boolean", + nullable: false, + comment: "是否允许叠加其他优惠。", + oldClrType: typeof(bool), + oldType: "boolean"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "coupon_templates", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UserId", + table: "community_reactions", + type: "uuid", + nullable: false, + comment: "用户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "community_reactions", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "community_reactions", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "community_reactions", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "ReactionType", + table: "community_reactions", + type: "integer", + nullable: false, + comment: "反应类型。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "ReactedAt", + table: "community_reactions", + type: "timestamp with time zone", + nullable: false, + comment: "时间戳。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "PostId", + table: "community_reactions", + type: "uuid", + nullable: false, + comment: "动态 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "community_reactions", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "community_reactions", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "community_reactions", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "community_reactions", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "community_reactions", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "community_posts", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "community_posts", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Title", + table: "community_posts", + type: "character varying(128)", + maxLength: 128, + nullable: true, + comment: "标题。", + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "community_posts", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "community_posts", + type: "integer", + nullable: false, + comment: "状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "MediaJson", + table: "community_posts", + type: "text", + nullable: true, + comment: "媒体资源 JSON。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "LikeCount", + table: "community_posts", + type: "integer", + nullable: false, + comment: "点赞数。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "community_posts", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "community_posts", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "community_posts", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "community_posts", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Content", + table: "community_posts", + type: "text", + nullable: false, + comment: "内容。", + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CommentCount", + table: "community_posts", + type: "integer", + nullable: false, + comment: "评论数。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "AuthorUserId", + table: "community_posts", + type: "uuid", + nullable: false, + comment: "作者用户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "community_posts", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "community_comments", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "community_comments", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "community_comments", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "PostId", + table: "community_comments", + type: "uuid", + nullable: false, + comment: "动态标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "ParentId", + table: "community_comments", + type: "uuid", + nullable: true, + comment: "父级评论 ID。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "IsDeleted", + table: "community_comments", + type: "boolean", + nullable: false, + comment: "状态。", + oldClrType: typeof(bool), + oldType: "boolean"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "community_comments", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "community_comments", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "community_comments", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "community_comments", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Content", + table: "community_comments", + type: "character varying(512)", + maxLength: 512, + nullable: false, + comment: "评论内容。", + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512); + + migrationBuilder.AlterColumn( + name: "AuthorUserId", + table: "community_comments", + type: "uuid", + nullable: false, + comment: "评论人。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "community_comments", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "ValidationResultJson", + table: "checkout_sessions", + type: "text", + nullable: false, + comment: "校验结果明细 JSON。", + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "UserId", + table: "checkout_sessions", + type: "uuid", + nullable: false, + comment: "用户标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "checkout_sessions", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "checkout_sessions", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "checkout_sessions", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "checkout_sessions", + type: "uuid", + nullable: false, + comment: "门店标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "checkout_sessions", + type: "integer", + nullable: false, + comment: "会话状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "SessionToken", + table: "checkout_sessions", + type: "character varying(64)", + maxLength: 64, + nullable: false, + comment: "会话 Token。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64); + + migrationBuilder.AlterColumn( + name: "ExpiresAt", + table: "checkout_sessions", + type: "timestamp with time zone", + nullable: false, + comment: "过期时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "checkout_sessions", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "checkout_sessions", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "checkout_sessions", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "checkout_sessions", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "checkout_sessions", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UserId", + table: "checkin_records", + type: "uuid", + nullable: false, + comment: "用户标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "checkin_records", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "checkin_records", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "checkin_records", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "RewardJson", + table: "checkin_records", + type: "text", + nullable: false, + comment: "获得奖励 JSON。", + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "IsMakeup", + table: "checkin_records", + type: "boolean", + nullable: false, + comment: "是否补签。", + oldClrType: typeof(bool), + oldType: "boolean"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "checkin_records", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "checkin_records", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "checkin_records", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "checkin_records", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "CheckInDate", + table: "checkin_records", + type: "timestamp with time zone", + nullable: false, + comment: "签到日期(本地)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "CheckInCampaignId", + table: "checkin_records", + type: "uuid", + nullable: false, + comment: "活动标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "checkin_records", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "checkin_campaigns", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "checkin_campaigns", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "checkin_campaigns", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "checkin_campaigns", + type: "integer", + nullable: false, + comment: "状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "StartDate", + table: "checkin_campaigns", + type: "timestamp with time zone", + nullable: false, + comment: "开始日期。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "RewardsJson", + table: "checkin_campaigns", + type: "text", + nullable: false, + comment: "连签奖励 JSON。", + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "checkin_campaigns", + type: "character varying(128)", + maxLength: 128, + nullable: false, + comment: "活动名称。", + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128); + + migrationBuilder.AlterColumn( + name: "EndDate", + table: "checkin_campaigns", + type: "timestamp with time zone", + nullable: false, + comment: "结束日期。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Description", + table: "checkin_campaigns", + type: "character varying(512)", + maxLength: 512, + nullable: true, + comment: "活动描述。", + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "checkin_campaigns", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "checkin_campaigns", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "checkin_campaigns", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "checkin_campaigns", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "AllowMakeupCount", + table: "checkin_campaigns", + type: "integer", + nullable: false, + comment: "支持补签次数。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "checkin_campaigns", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "chat_sessions", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "chat_sessions", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "chat_sessions", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "chat_sessions", + type: "uuid", + nullable: true, + comment: "所属门店(可空为平台)。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Status", + table: "chat_sessions", + type: "integer", + nullable: false, + comment: "会话状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "StartedAt", + table: "chat_sessions", + type: "timestamp with time zone", + nullable: false, + comment: "开始时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "SessionCode", + table: "chat_sessions", + type: "character varying(64)", + maxLength: 64, + nullable: false, + comment: "会话编号。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64); + + migrationBuilder.AlterColumn( + name: "IsBotActive", + table: "chat_sessions", + type: "boolean", + nullable: false, + comment: "是否机器人接待中。", + oldClrType: typeof(bool), + oldType: "boolean"); + + migrationBuilder.AlterColumn( + name: "EndedAt", + table: "chat_sessions", + type: "timestamp with time zone", + nullable: true, + comment: "结束时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "chat_sessions", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "chat_sessions", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CustomerUserId", + table: "chat_sessions", + type: "uuid", + nullable: false, + comment: "顾客用户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "chat_sessions", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "chat_sessions", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "AgentUserId", + table: "chat_sessions", + type: "uuid", + nullable: true, + comment: "当前客服员工 ID。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Id", + table: "chat_sessions", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "chat_messages", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "chat_messages", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "chat_messages", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "SenderUserId", + table: "chat_messages", + type: "uuid", + nullable: true, + comment: "发送方用户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "SenderType", + table: "chat_messages", + type: "integer", + nullable: false, + comment: "发送方类型。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "ReadAt", + table: "chat_messages", + type: "timestamp with time zone", + nullable: true, + comment: "读取时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "IsRead", + table: "chat_messages", + type: "boolean", + nullable: false, + comment: "是否已读。", + oldClrType: typeof(bool), + oldType: "boolean"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "chat_messages", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "chat_messages", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "chat_messages", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "chat_messages", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "ContentType", + table: "chat_messages", + type: "character varying(64)", + maxLength: 64, + nullable: false, + comment: "消息类型(文字/图片/语音等)。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64); + + migrationBuilder.AlterColumn( + name: "Content", + table: "chat_messages", + type: "character varying(1024)", + maxLength: 1024, + nullable: false, + comment: "消息内容。", + oldClrType: typeof(string), + oldType: "character varying(1024)", + oldMaxLength: 1024); + + migrationBuilder.AlterColumn( + name: "ChatSessionId", + table: "chat_messages", + type: "uuid", + nullable: false, + comment: "会话标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "chat_messages", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "cart_items", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "cart_items", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UnitPrice", + table: "cart_items", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + comment: "单价快照。", + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "cart_items", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "cart_items", + type: "integer", + nullable: false, + comment: "状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "ShoppingCartId", + table: "cart_items", + type: "uuid", + nullable: false, + comment: "所属购物车标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Remark", + table: "cart_items", + type: "character varying(256)", + maxLength: 256, + nullable: true, + comment: "自定义备注(口味要求)。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Quantity", + table: "cart_items", + type: "integer", + nullable: false, + comment: "数量。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "ProductSkuId", + table: "cart_items", + type: "uuid", + nullable: true, + comment: "SKU 标识。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ProductName", + table: "cart_items", + type: "character varying(128)", + maxLength: 128, + nullable: false, + comment: "商品名称快照。", + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128); + + migrationBuilder.AlterColumn( + name: "ProductId", + table: "cart_items", + type: "uuid", + nullable: false, + comment: "商品或 SKU 标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "cart_items", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "cart_items", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "cart_items", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "cart_items", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "AttributesJson", + table: "cart_items", + type: "text", + nullable: true, + comment: "扩展 JSON(规格、加料选项等)。", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Id", + table: "cart_items", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "cart_item_addons", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "cart_item_addons", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "cart_item_addons", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "OptionId", + table: "cart_item_addons", + type: "uuid", + nullable: true, + comment: "选项 ID(可对应 ProductAddonOption)。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Name", + table: "cart_item_addons", + type: "character varying(64)", + maxLength: 64, + nullable: false, + comment: "选项名称。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64); + + migrationBuilder.AlterColumn( + name: "ExtraPrice", + table: "cart_item_addons", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + comment: "附加价格。", + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "cart_item_addons", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "cart_item_addons", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "cart_item_addons", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "cart_item_addons", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "CartItemId", + table: "cart_item_addons", + type: "uuid", + nullable: false, + comment: "所属购物车条目。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "cart_item_addons", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "affiliate_payouts", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "affiliate_payouts", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "affiliate_payouts", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "affiliate_payouts", + type: "integer", + nullable: false, + comment: "状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "Remarks", + table: "affiliate_payouts", + type: "character varying(256)", + maxLength: 256, + nullable: true, + comment: "备注。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Period", + table: "affiliate_payouts", + type: "character varying(32)", + maxLength: 32, + nullable: false, + comment: "结算周期描述。", + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32); + + migrationBuilder.AlterColumn( + name: "PaidAt", + table: "affiliate_payouts", + type: "timestamp with time zone", + nullable: true, + comment: "打款时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "affiliate_payouts", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "affiliate_payouts", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "affiliate_payouts", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "affiliate_payouts", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Amount", + table: "affiliate_payouts", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + comment: "结算金额。", + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2); + + migrationBuilder.AlterColumn( + name: "AffiliatePartnerId", + table: "affiliate_payouts", + type: "uuid", + nullable: false, + comment: "合作伙伴标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "affiliate_payouts", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UserId", + table: "affiliate_partners", + type: "uuid", + nullable: true, + comment: "用户 ID(如绑定平台账号)。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "affiliate_partners", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "affiliate_partners", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "affiliate_partners", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "affiliate_partners", + type: "integer", + nullable: false, + comment: "当前状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "Remarks", + table: "affiliate_partners", + type: "character varying(256)", + maxLength: 256, + nullable: true, + comment: "审核备注。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Phone", + table: "affiliate_partners", + type: "character varying(32)", + maxLength: 32, + nullable: true, + comment: "联系电话。", + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DisplayName", + table: "affiliate_partners", + type: "character varying(64)", + maxLength: 64, + nullable: false, + comment: "昵称或渠道名称。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "affiliate_partners", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "affiliate_partners", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "affiliate_partners", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "affiliate_partners", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "CommissionRate", + table: "affiliate_partners", + type: "numeric", + nullable: false, + comment: "分成比例(0-1)。", + oldClrType: typeof(decimal), + oldType: "numeric"); + + migrationBuilder.AlterColumn( + name: "ChannelType", + table: "affiliate_partners", + type: "integer", + nullable: false, + comment: "渠道类型。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "affiliate_partners", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "affiliate_orders", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "affiliate_orders", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "affiliate_orders", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "affiliate_orders", + type: "integer", + nullable: false, + comment: "当前状态。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "SettledAt", + table: "affiliate_orders", + type: "timestamp with time zone", + nullable: true, + comment: "结算完成时间。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "OrderId", + table: "affiliate_orders", + type: "uuid", + nullable: false, + comment: "关联订单。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "OrderAmount", + table: "affiliate_orders", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + comment: "订单金额。", + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2); + + migrationBuilder.AlterColumn( + name: "EstimatedCommission", + table: "affiliate_orders", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + comment: "预计佣金。", + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "affiliate_orders", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "affiliate_orders", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "affiliate_orders", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "affiliate_orders", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "BuyerUserId", + table: "affiliate_orders", + type: "uuid", + nullable: false, + comment: "用户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "AffiliatePartnerId", + table: "affiliate_orders", + type: "uuid", + nullable: false, + comment: "推广人标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "affiliate_orders", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterTable( + name: "ticket_comments", + oldComment: "工单评论/流转记录。"); + + migrationBuilder.AlterTable( + name: "tenants", + oldComment: "平台租户信息,描述租户的生命周期与基础资料。"); + + migrationBuilder.AlterTable( + name: "tenant_subscriptions", + oldComment: "租户套餐订阅记录。"); + + migrationBuilder.AlterTable( + name: "tenant_quota_usages", + oldComment: "租户配额使用情况快照。"); + + migrationBuilder.AlterTable( + name: "tenant_packages", + oldComment: "平台提供的租户套餐定义。"); + + migrationBuilder.AlterTable( + name: "tenant_notifications", + oldComment: "面向租户的站内通知或消息推送。"); + + migrationBuilder.AlterTable( + name: "tenant_billing_statements", + oldComment: "租户账单,用于呈现周期性收费。"); + + migrationBuilder.AlterTable( + name: "support_tickets", + oldComment: "客服工单。"); + + migrationBuilder.AlterTable( + name: "stores", + oldComment: "门店信息,承载营业配置与能力。"); + + migrationBuilder.AlterTable( + name: "store_tables", + oldComment: "桌台信息与二维码绑定。"); + + migrationBuilder.AlterTable( + name: "store_table_areas", + oldComment: "门店桌台区域配置。"); + + migrationBuilder.AlterTable( + name: "store_holidays", + oldComment: "门店休息日或特殊营业日。"); + + migrationBuilder.AlterTable( + name: "store_employee_shifts", + oldComment: "门店员工排班记录。"); + + migrationBuilder.AlterTable( + name: "store_delivery_zones", + oldComment: "门店配送范围配置。"); + + migrationBuilder.AlterTable( + name: "store_business_hours", + oldComment: "门店营业时段配置。"); + + migrationBuilder.AlterTable( + name: "shopping_carts", + oldComment: "用户购物车,按租户/门店隔离。"); + + migrationBuilder.AlterTable( + name: "reservations", + oldComment: "预约/预订记录。"); + + migrationBuilder.AlterTable( + name: "refund_requests", + oldComment: "售后/退款申请。"); + + migrationBuilder.AlterTable( + name: "queue_tickets", + oldComment: "排队叫号。"); + + migrationBuilder.AlterTable( + name: "promotion_campaigns", + oldComment: "营销活动配置。"); + + migrationBuilder.AlterTable( + name: "products", + oldComment: "商品(SPU)信息。"); + + migrationBuilder.AlterTable( + name: "product_skus", + oldComment: "商品 SKU,记录具体规格组合价格。"); + + migrationBuilder.AlterTable( + name: "product_pricing_rules", + oldComment: "商品价格策略,支持会员价/时段价等。"); + + migrationBuilder.AlterTable( + name: "product_media_assets", + oldComment: "商品媒资素材。"); + + migrationBuilder.AlterTable( + name: "product_categories", + oldComment: "商品分类。"); + + migrationBuilder.AlterTable( + name: "product_attribute_options", + oldComment: "商品规格选项。"); + + migrationBuilder.AlterTable( + name: "product_attribute_groups", + oldComment: "商品规格/属性分组。"); + + migrationBuilder.AlterTable( + name: "product_addon_options", + oldComment: "加料选项。"); + + migrationBuilder.AlterTable( + name: "product_addon_groups", + oldComment: "加料/做法分组。"); + + migrationBuilder.AlterTable( + name: "payment_refund_records", + oldComment: "支付渠道退款流水。"); + + migrationBuilder.AlterTable( + name: "payment_records", + oldComment: "支付流水。"); + + migrationBuilder.AlterTable( + name: "orders", + oldComment: "交易订单。"); + + migrationBuilder.AlterTable( + name: "order_status_histories", + oldComment: "订单状态流转记录。"); + + migrationBuilder.AlterTable( + name: "order_items", + oldComment: "订单明细。"); + + migrationBuilder.AlterTable( + name: "navigation_requests", + oldComment: "用户发起的导航请求日志。"); + + migrationBuilder.AlterTable( + name: "metric_snapshots", + oldComment: "指标快照,用于大盘展示。"); + + migrationBuilder.AlterTable( + name: "metric_definitions", + oldComment: "指标定义,描述可观测的数据点。"); + + migrationBuilder.AlterTable( + name: "metric_alert_rules", + oldComment: "指标告警规则。"); + + migrationBuilder.AlterTable( + name: "merchants", + oldComment: "商户主体信息,承载入驻和资质审核结果。"); + + migrationBuilder.AlterTable( + name: "merchant_staff", + oldComment: "商户员工账号,支持门店维度分配。"); + + migrationBuilder.AlterTable( + name: "merchant_documents", + oldComment: "商户提交的资质或证照材料。"); + + migrationBuilder.AlterTable( + name: "merchant_contracts", + oldComment: "商户合同记录。"); + + migrationBuilder.AlterTable( + name: "member_tiers", + oldComment: "会员等级定义。"); + + migrationBuilder.AlterTable( + name: "member_profiles", + oldComment: "会员档案。"); + + migrationBuilder.AlterTable( + name: "member_point_ledgers", + oldComment: "积分变动流水。"); + + migrationBuilder.AlterTable( + name: "member_growth_logs", + oldComment: "成长值变动日志。"); + + migrationBuilder.AlterTable( + name: "map_locations", + oldComment: "地图 POI 信息,用于门店定位和推荐。"); + + migrationBuilder.AlterTable( + name: "inventory_items", + oldComment: "SKU 在门店的库存信息。"); + + migrationBuilder.AlterTable( + name: "inventory_batches", + oldComment: "SKU 批次信息。"); + + migrationBuilder.AlterTable( + name: "inventory_adjustments", + oldComment: "库存调整记录。"); + + migrationBuilder.AlterTable( + name: "group_participants", + oldComment: "拼单参与者。"); + + migrationBuilder.AlterTable( + name: "group_orders", + oldComment: "拼单活动。"); + + migrationBuilder.AlterTable( + name: "delivery_orders", + oldComment: "配送单。"); + + migrationBuilder.AlterTable( + name: "delivery_events", + oldComment: "配送状态事件流水。"); + + migrationBuilder.AlterTable( + name: "coupons", + oldComment: "用户领取的券。"); + + migrationBuilder.AlterTable( + name: "coupon_templates", + oldComment: "优惠券模板。"); + + migrationBuilder.AlterTable( + name: "community_reactions", + oldComment: "社区互动反馈。"); + + migrationBuilder.AlterTable( + name: "community_posts", + oldComment: "社区动态。"); + + migrationBuilder.AlterTable( + name: "community_comments", + oldComment: "社区评论。"); + + migrationBuilder.AlterTable( + name: "checkout_sessions", + oldComment: "结账会话,记录校验上下文。"); + + migrationBuilder.AlterTable( + name: "checkin_records", + oldComment: "用户签到记录。"); + + migrationBuilder.AlterTable( + name: "checkin_campaigns", + oldComment: "签到活动配置。"); + + migrationBuilder.AlterTable( + name: "chat_sessions", + oldComment: "客服会话。"); + + migrationBuilder.AlterTable( + name: "chat_messages", + oldComment: "会话消息。"); + + migrationBuilder.AlterTable( + name: "cart_items", + oldComment: "购物车条目。"); + + migrationBuilder.AlterTable( + name: "cart_item_addons", + oldComment: "购物车条目的加料/附加项。"); + + migrationBuilder.AlterTable( + name: "affiliate_payouts", + oldComment: "佣金结算记录。"); + + migrationBuilder.AlterTable( + name: "affiliate_partners", + oldComment: "分销/推广合作伙伴。"); + + migrationBuilder.AlterTable( + name: "affiliate_orders", + oldComment: "分销订单记录。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "ticket_comments", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "ticket_comments", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "ticket_comments", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "SupportTicketId", + table: "ticket_comments", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "工单标识。"); + + migrationBuilder.AlterColumn( + name: "IsInternal", + table: "ticket_comments", + type: "boolean", + nullable: false, + oldClrType: typeof(bool), + oldType: "boolean", + oldComment: "是否内部备注。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "ticket_comments", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "ticket_comments", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "ticket_comments", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "ticket_comments", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Content", + table: "ticket_comments", + type: "character varying(1024)", + maxLength: 1024, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(1024)", + oldMaxLength: 1024, + oldComment: "评论内容。"); + + migrationBuilder.AlterColumn( + name: "AuthorUserId", + table: "ticket_comments", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "评论人 ID。"); + + migrationBuilder.AlterColumn( + name: "AttachmentsJson", + table: "ticket_comments", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "附件 JSON。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "ticket_comments", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "Website", + table: "tenants", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "官网或主要宣传链接。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "tenants", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "tenants", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "Tags", + table: "tenants", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "业务标签集合(逗号分隔)。"); + + migrationBuilder.AlterColumn( + name: "SuspensionReason", + table: "tenants", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "暂停或终止的原因说明。"); + + migrationBuilder.AlterColumn( + name: "SuspendedAt", + table: "tenants", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次暂停服务时间。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "tenants", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "租户当前状态,涵盖审核、启用、停用等场景。"); + + migrationBuilder.AlterColumn( + name: "ShortName", + table: "tenants", + type: "character varying(64)", + maxLength: 64, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true, + oldComment: "对外展示的简称。"); + + migrationBuilder.AlterColumn( + name: "Remarks", + table: "tenants", + type: "character varying(512)", + maxLength: 512, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldNullable: true, + oldComment: "备注信息,用于运营记录特殊说明。"); + + migrationBuilder.AlterColumn( + name: "Province", + table: "tenants", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "所在省份或州。"); + + migrationBuilder.AlterColumn( + name: "PrimaryOwnerUserId", + table: "tenants", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "系统内对应的租户所有者账号 ID。"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "tenants", + type: "character varying(128)", + maxLength: 128, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldComment: "租户全称或品牌名称。"); + + migrationBuilder.AlterColumn( + name: "LogoUrl", + table: "tenants", + type: "character varying(256)", + maxLength: 256, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true, + oldComment: "LOGO 图片地址。"); + + migrationBuilder.AlterColumn( + name: "LegalEntityName", + table: "tenants", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "法人或公司主体名称。"); + + migrationBuilder.AlterColumn( + name: "Industry", + table: "tenants", + type: "character varying(64)", + maxLength: 64, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true, + oldComment: "所属行业,如餐饮、零售等。"); + + migrationBuilder.AlterColumn( + name: "EffectiveTo", + table: "tenants", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "服务到期时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "EffectiveFrom", + table: "tenants", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "服务生效时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "tenants", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "tenants", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "tenants", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "tenants", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "CoverImageUrl", + table: "tenants", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "品牌海报或封面图。"); + + migrationBuilder.AlterColumn( + name: "Country", + table: "tenants", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "所在国家/地区。"); + + migrationBuilder.AlterColumn( + name: "ContactPhone", + table: "tenants", + type: "character varying(32)", + maxLength: 32, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldNullable: true, + oldComment: "主联系人电话。"); + + migrationBuilder.AlterColumn( + name: "ContactName", + table: "tenants", + type: "character varying(64)", + maxLength: 64, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true, + oldComment: "主联系人姓名。"); + + migrationBuilder.AlterColumn( + name: "ContactEmail", + table: "tenants", + type: "character varying(128)", + maxLength: 128, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldNullable: true, + oldComment: "主联系人邮箱。"); + + migrationBuilder.AlterColumn( + name: "Code", + table: "tenants", + type: "character varying(64)", + maxLength: 64, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldComment: "租户短编码,作为跨系统引用的唯一标识。"); + + migrationBuilder.AlterColumn( + name: "City", + table: "tenants", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "所在城市。"); + + migrationBuilder.AlterColumn( + name: "Address", + table: "tenants", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "详细地址信息。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "tenants", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "tenant_subscriptions", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "tenant_subscriptions", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantPackageId", + table: "tenant_subscriptions", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "当前订阅关联的套餐标识。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "tenant_subscriptions", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "tenant_subscriptions", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "订阅当前状态。"); + + migrationBuilder.AlterColumn( + name: "ScheduledPackageId", + table: "tenant_subscriptions", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "若已排期升降配,对应的新套餐 ID。"); + + migrationBuilder.AlterColumn( + name: "Notes", + table: "tenant_subscriptions", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "运营备注信息。"); + + migrationBuilder.AlterColumn( + name: "NextBillingDate", + table: "tenant_subscriptions", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "下一个计费时间,配合自动续费使用。"); + + migrationBuilder.AlterColumn( + name: "EffectiveTo", + table: "tenant_subscriptions", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "订阅到期时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "EffectiveFrom", + table: "tenant_subscriptions", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "订阅生效时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "tenant_subscriptions", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "tenant_subscriptions", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "tenant_subscriptions", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "tenant_subscriptions", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "AutoRenew", + table: "tenant_subscriptions", + type: "boolean", + nullable: false, + oldClrType: typeof(bool), + oldType: "boolean", + oldComment: "是否开启自动续费。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "tenant_subscriptions", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UsedValue", + table: "tenant_quota_usages", + type: "numeric", + nullable: false, + oldClrType: typeof(decimal), + oldType: "numeric", + oldComment: "已消耗的数量。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "tenant_quota_usages", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "tenant_quota_usages", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "tenant_quota_usages", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "ResetCycle", + table: "tenant_quota_usages", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "配额刷新周期描述(如月、年)。"); + + migrationBuilder.AlterColumn( + name: "QuotaType", + table: "tenant_quota_usages", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "配额类型,例如门店数、短信条数等。"); + + migrationBuilder.AlterColumn( + name: "LimitValue", + table: "tenant_quota_usages", + type: "numeric", + nullable: false, + oldClrType: typeof(decimal), + oldType: "numeric", + oldComment: "当前配额上限。"); + + migrationBuilder.AlterColumn( + name: "LastResetAt", + table: "tenant_quota_usages", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次重置时间。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "tenant_quota_usages", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "tenant_quota_usages", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "tenant_quota_usages", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "tenant_quota_usages", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "tenant_quota_usages", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "YearlyPrice", + table: "tenant_packages", + type: "numeric", + nullable: true, + oldClrType: typeof(decimal), + oldType: "numeric", + oldNullable: true, + oldComment: "年付价格,单位:人民币元。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "tenant_packages", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "tenant_packages", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "PackageType", + table: "tenant_packages", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "套餐分类(试用、标准、旗舰等)。"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "tenant_packages", + type: "character varying(128)", + maxLength: 128, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldComment: "套餐名称,展示给租户的简称。"); + + migrationBuilder.AlterColumn( + name: "MonthlyPrice", + table: "tenant_packages", + type: "numeric", + nullable: true, + oldClrType: typeof(decimal), + oldType: "numeric", + oldNullable: true, + oldComment: "月付价格,单位:人民币元。"); + + migrationBuilder.AlterColumn( + name: "MaxStoreCount", + table: "tenant_packages", + type: "integer", + nullable: true, + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true, + oldComment: "允许的最大门店数。"); + + migrationBuilder.AlterColumn( + name: "MaxStorageGb", + table: "tenant_packages", + type: "integer", + nullable: true, + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true, + oldComment: "存储容量上限(GB)。"); + + migrationBuilder.AlterColumn( + name: "MaxSmsCredits", + table: "tenant_packages", + type: "integer", + nullable: true, + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true, + oldComment: "每月短信额度上限。"); + + migrationBuilder.AlterColumn( + name: "MaxDeliveryOrders", + table: "tenant_packages", + type: "integer", + nullable: true, + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true, + oldComment: "每月可调用的配送单数量上限。"); + + migrationBuilder.AlterColumn( + name: "MaxAccountCount", + table: "tenant_packages", + type: "integer", + nullable: true, + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true, + oldComment: "允许创建的最大账号数。"); + + migrationBuilder.AlterColumn( + name: "IsActive", + table: "tenant_packages", + type: "boolean", + nullable: false, + oldClrType: typeof(bool), + oldType: "boolean", + oldComment: "是否仍可售卖。"); + + migrationBuilder.AlterColumn( + name: "FeaturePoliciesJson", + table: "tenant_packages", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "权益明细 JSON,记录自定义特性开关。"); + + migrationBuilder.AlterColumn( + name: "Description", + table: "tenant_packages", + type: "character varying(512)", + maxLength: 512, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldNullable: true, + oldComment: "套餐描述,包含适用场景、权益等。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "tenant_packages", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "tenant_packages", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "tenant_packages", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "tenant_packages", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "tenant_packages", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "tenant_notifications", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "tenant_notifications", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "Title", + table: "tenant_notifications", + type: "character varying(128)", + maxLength: 128, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldComment: "通知标题。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "tenant_notifications", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "Severity", + table: "tenant_notifications", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "通知重要级别。"); + + migrationBuilder.AlterColumn( + name: "SentAt", + table: "tenant_notifications", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "推送时间。"); + + migrationBuilder.AlterColumn( + name: "ReadAt", + table: "tenant_notifications", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "租户是否已阅读。"); + + migrationBuilder.AlterColumn( + name: "MetadataJson", + table: "tenant_notifications", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "附加元数据 JSON。"); + + migrationBuilder.AlterColumn( + name: "Message", + table: "tenant_notifications", + type: "character varying(1024)", + maxLength: 1024, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(1024)", + oldMaxLength: 1024, + oldComment: "通知正文。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "tenant_notifications", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "tenant_notifications", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "tenant_notifications", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "tenant_notifications", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Channel", + table: "tenant_notifications", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "发布通道(站内、邮件、短信等)。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "tenant_notifications", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "tenant_billing_statements", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "tenant_billing_statements", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "tenant_billing_statements", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "tenant_billing_statements", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "当前付款状态。"); + + migrationBuilder.AlterColumn( + name: "StatementNo", + table: "tenant_billing_statements", + type: "character varying(64)", + maxLength: 64, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldComment: "账单编号,供对账查询。"); + + migrationBuilder.AlterColumn( + name: "PeriodStart", + table: "tenant_billing_statements", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "账单周期开始时间。"); + + migrationBuilder.AlterColumn( + name: "PeriodEnd", + table: "tenant_billing_statements", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "账单周期结束时间。"); + + migrationBuilder.AlterColumn( + name: "LineItemsJson", + table: "tenant_billing_statements", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "账单明细 JSON,记录各项费用。"); + + migrationBuilder.AlterColumn( + name: "DueDate", + table: "tenant_billing_statements", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "到期日。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "tenant_billing_statements", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "tenant_billing_statements", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "tenant_billing_statements", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "tenant_billing_statements", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "AmountPaid", + table: "tenant_billing_statements", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldComment: "实付金额。"); + + migrationBuilder.AlterColumn( + name: "AmountDue", + table: "tenant_billing_statements", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldComment: "应付金额。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "tenant_billing_statements", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "support_tickets", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "support_tickets", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TicketNo", + table: "support_tickets", + type: "character varying(32)", + maxLength: 32, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldComment: "工单编号。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "support_tickets", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "Subject", + table: "support_tickets", + type: "character varying(128)", + maxLength: 128, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldComment: "工单主题。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "support_tickets", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "状态。"); + + migrationBuilder.AlterColumn( + name: "Priority", + table: "support_tickets", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "优先级。"); + + migrationBuilder.AlterColumn( + name: "OrderId", + table: "support_tickets", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "关联订单(如有)。"); + + migrationBuilder.AlterColumn( + name: "Description", + table: "support_tickets", + type: "text", + nullable: false, + oldClrType: typeof(string), + oldType: "text", + oldComment: "工单详情。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "support_tickets", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "support_tickets", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CustomerUserId", + table: "support_tickets", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "客户用户 ID。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "support_tickets", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "support_tickets", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "ClosedAt", + table: "support_tickets", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "关闭时间。"); + + migrationBuilder.AlterColumn( + name: "AssignedAgentId", + table: "support_tickets", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "指派的客服。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "support_tickets", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "stores", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "stores", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "stores", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "Tags", + table: "stores", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "门店标签(逗号分隔)。"); + + migrationBuilder.AlterColumn( + name: "SupportsReservation", + table: "stores", + type: "boolean", + nullable: false, + oldClrType: typeof(bool), + oldType: "boolean", + oldComment: "支持预约。"); + + migrationBuilder.AlterColumn( + name: "SupportsQueueing", + table: "stores", + type: "boolean", + nullable: false, + oldClrType: typeof(bool), + oldType: "boolean", + oldComment: "支持排队叫号。"); + + migrationBuilder.AlterColumn( + name: "SupportsPickup", + table: "stores", + type: "boolean", + nullable: false, + oldClrType: typeof(bool), + oldType: "boolean", + oldComment: "是否支持自提。"); + + migrationBuilder.AlterColumn( + name: "SupportsDineIn", + table: "stores", + type: "boolean", + nullable: false, + oldClrType: typeof(bool), + oldType: "boolean", + oldComment: "是否支持堂食。"); + + migrationBuilder.AlterColumn( + name: "SupportsDelivery", + table: "stores", + type: "boolean", + nullable: false, + oldClrType: typeof(bool), + oldType: "boolean", + oldComment: "是否支持配送。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "stores", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "门店当前运营状态。"); + + migrationBuilder.AlterColumn( + name: "Province", + table: "stores", + type: "character varying(64)", + maxLength: 64, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true, + oldComment: "所在省份。"); + + migrationBuilder.AlterColumn( + name: "Phone", + table: "stores", + type: "character varying(32)", + maxLength: 32, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldNullable: true, + oldComment: "联系电话。"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "stores", + type: "character varying(128)", + maxLength: 128, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldComment: "门店名称。"); + + migrationBuilder.AlterColumn( + name: "MerchantId", + table: "stores", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属商户标识。"); + + migrationBuilder.AlterColumn( + name: "ManagerName", + table: "stores", + type: "character varying(64)", + maxLength: 64, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true, + oldComment: "门店负责人姓名。"); + + migrationBuilder.AlterColumn( + name: "Longitude", + table: "stores", + type: "double precision", + nullable: true, + oldClrType: typeof(double), + oldType: "double precision", + oldNullable: true, + oldComment: "高德/腾讯地图经度。"); + + migrationBuilder.AlterColumn( + name: "Latitude", + table: "stores", + type: "double precision", + nullable: true, + oldClrType: typeof(double), + oldType: "double precision", + oldNullable: true, + oldComment: "纬度。"); + + migrationBuilder.AlterColumn( + name: "District", + table: "stores", + type: "character varying(64)", + maxLength: 64, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true, + oldComment: "区县信息。"); + + migrationBuilder.AlterColumn( + name: "Description", + table: "stores", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "门店描述或公告。"); + + migrationBuilder.AlterColumn( + name: "DeliveryRadiusKm", + table: "stores", + type: "numeric(6,2)", + precision: 6, + scale: 2, + nullable: false, + oldClrType: typeof(decimal), + oldType: "numeric(6,2)", + oldPrecision: 6, + oldScale: 2, + oldComment: "默认配送半径(公里)。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "stores", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "stores", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "stores", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "stores", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "CoverImageUrl", + table: "stores", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "门店海报。"); + + migrationBuilder.AlterColumn( + name: "Country", + table: "stores", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "所在国家或地区。"); + + migrationBuilder.AlterColumn( + name: "Code", + table: "stores", + type: "character varying(32)", + maxLength: 32, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldComment: "门店编码,便于扫码及外部对接。"); + + migrationBuilder.AlterColumn( + name: "City", + table: "stores", + type: "character varying(64)", + maxLength: 64, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true, + oldComment: "所在城市。"); + + migrationBuilder.AlterColumn( + name: "BusinessHours", + table: "stores", + type: "character varying(256)", + maxLength: 256, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true, + oldComment: "门店营业时段描述(备用字符串)。"); + + migrationBuilder.AlterColumn( + name: "Announcement", + table: "stores", + type: "character varying(512)", + maxLength: 512, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldNullable: true, + oldComment: "门店公告。"); + + migrationBuilder.AlterColumn( + name: "Address", + table: "stores", + type: "character varying(256)", + maxLength: 256, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true, + oldComment: "详细地址。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "stores", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "store_tables", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "store_tables", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "store_tables", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "Tags", + table: "store_tables", + type: "character varying(128)", + maxLength: 128, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldNullable: true, + oldComment: "桌台标签(堂食、快餐等)。"); + + migrationBuilder.AlterColumn( + name: "TableCode", + table: "store_tables", + type: "character varying(32)", + maxLength: 32, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldComment: "桌码。"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "store_tables", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "门店标识。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "store_tables", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "当前桌台状态。"); + + migrationBuilder.AlterColumn( + name: "QrCodeUrl", + table: "store_tables", + type: "character varying(512)", + maxLength: 512, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldNullable: true, + oldComment: "桌码二维码地址。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "store_tables", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "store_tables", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "store_tables", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "store_tables", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Capacity", + table: "store_tables", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "可容纳人数。"); + + migrationBuilder.AlterColumn( + name: "AreaId", + table: "store_tables", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "所在区域 ID。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "store_tables", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "store_table_areas", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "store_table_areas", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "store_table_areas", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "store_table_areas", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "门店标识。"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "store_table_areas", + type: "character varying(64)", + maxLength: 64, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldComment: "区域名称。"); + + migrationBuilder.AlterColumn( + name: "Description", + table: "store_table_areas", + type: "character varying(256)", + maxLength: 256, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true, + oldComment: "区域描述。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "store_table_areas", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "store_table_areas", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "store_table_areas", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "store_table_areas", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "store_table_areas", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "store_holidays", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "store_holidays", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "store_holidays", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "store_holidays", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "门店标识。"); + + migrationBuilder.AlterColumn( + name: "Reason", + table: "store_holidays", + type: "character varying(256)", + maxLength: 256, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true, + oldComment: "说明内容。"); + + migrationBuilder.AlterColumn( + name: "IsClosed", + table: "store_holidays", + type: "boolean", + nullable: false, + oldClrType: typeof(bool), + oldType: "boolean", + oldComment: "是否全天闭店。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "store_holidays", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "store_holidays", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "Date", + table: "store_holidays", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "日期。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "store_holidays", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "store_holidays", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "store_holidays", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "store_employee_shifts", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "store_employee_shifts", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "store_employee_shifts", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "store_employee_shifts", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "门店标识。"); + + migrationBuilder.AlterColumn( + name: "StartTime", + table: "store_employee_shifts", + type: "interval", + nullable: false, + oldClrType: typeof(TimeSpan), + oldType: "interval", + oldComment: "开始时间。"); + + migrationBuilder.AlterColumn( + name: "StaffId", + table: "store_employee_shifts", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "员工标识。"); + + migrationBuilder.AlterColumn( + name: "ShiftDate", + table: "store_employee_shifts", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "班次日期。"); + + migrationBuilder.AlterColumn( + name: "RoleType", + table: "store_employee_shifts", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "排班角色。"); + + migrationBuilder.AlterColumn( + name: "Notes", + table: "store_employee_shifts", + type: "character varying(256)", + maxLength: 256, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true, + oldComment: "备注。"); + + migrationBuilder.AlterColumn( + name: "EndTime", + table: "store_employee_shifts", + type: "interval", + nullable: false, + oldClrType: typeof(TimeSpan), + oldType: "interval", + oldComment: "结束时间。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "store_employee_shifts", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "store_employee_shifts", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "store_employee_shifts", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "store_employee_shifts", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "store_employee_shifts", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "ZoneName", + table: "store_delivery_zones", + type: "character varying(64)", + maxLength: 64, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldComment: "区域名称。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "store_delivery_zones", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "store_delivery_zones", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "store_delivery_zones", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "store_delivery_zones", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "门店标识。"); + + migrationBuilder.AlterColumn( + name: "PolygonGeoJson", + table: "store_delivery_zones", + type: "text", + nullable: false, + oldClrType: typeof(string), + oldType: "text", + oldComment: "GeoJSON 表示的多边形范围。"); + + migrationBuilder.AlterColumn( + name: "MinimumOrderAmount", + table: "store_delivery_zones", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: true, + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldNullable: true, + oldComment: "起送价。"); + + migrationBuilder.AlterColumn( + name: "EstimatedMinutes", + table: "store_delivery_zones", + type: "integer", + nullable: true, + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true, + oldComment: "预计送达分钟。"); + + migrationBuilder.AlterColumn( + name: "DeliveryFee", + table: "store_delivery_zones", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: true, + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldNullable: true, + oldComment: "配送费。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "store_delivery_zones", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "store_delivery_zones", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "store_delivery_zones", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "store_delivery_zones", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "store_delivery_zones", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "store_business_hours", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "store_business_hours", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "store_business_hours", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "store_business_hours", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "门店标识。"); + + migrationBuilder.AlterColumn( + name: "StartTime", + table: "store_business_hours", + type: "interval", + nullable: false, + oldClrType: typeof(TimeSpan), + oldType: "interval", + oldComment: "开始时间(本地时间)。"); + + migrationBuilder.AlterColumn( + name: "Notes", + table: "store_business_hours", + type: "character varying(256)", + maxLength: 256, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true, + oldComment: "备注。"); + + migrationBuilder.AlterColumn( + name: "HourType", + table: "store_business_hours", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "时段类型(正常营业、休息、预约等)。"); + + migrationBuilder.AlterColumn( + name: "EndTime", + table: "store_business_hours", + type: "interval", + nullable: false, + oldClrType: typeof(TimeSpan), + oldType: "interval", + oldComment: "结束时间(本地时间)。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "store_business_hours", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "store_business_hours", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DayOfWeek", + table: "store_business_hours", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "星期几,0 表示周日。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "store_business_hours", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "store_business_hours", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "CapacityLimit", + table: "store_business_hours", + type: "integer", + nullable: true, + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true, + oldComment: "最大接待容量或单量限制。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "store_business_hours", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UserId", + table: "shopping_carts", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "用户标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "shopping_carts", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "shopping_carts", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "shopping_carts", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "TableContext", + table: "shopping_carts", + type: "character varying(64)", + maxLength: 64, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true, + oldComment: "桌码或场景标识(扫码点餐)。"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "shopping_carts", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "门店标识。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "shopping_carts", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "购物车状态,包含正常/锁定。"); + + migrationBuilder.AlterColumn( + name: "LastModifiedAt", + table: "shopping_carts", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "最近一次修改时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "DeliveryPreference", + table: "shopping_carts", + type: "character varying(32)", + maxLength: 32, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldNullable: true, + oldComment: "履约方式(堂食/自提/配送)缓存。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "shopping_carts", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "shopping_carts", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "shopping_carts", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "shopping_carts", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "shopping_carts", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "reservations", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "reservations", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "reservations", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "TablePreference", + table: "reservations", + type: "character varying(64)", + maxLength: 64, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true, + oldComment: "桌型/标签。"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "reservations", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "门店。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "reservations", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "状态。"); + + migrationBuilder.AlterColumn( + name: "ReservationTime", + table: "reservations", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "预约时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "ReservationNo", + table: "reservations", + type: "character varying(32)", + maxLength: 32, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldComment: "预约号。"); + + migrationBuilder.AlterColumn( + name: "Remark", + table: "reservations", + type: "character varying(512)", + maxLength: 512, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldNullable: true, + oldComment: "备注。"); + + migrationBuilder.AlterColumn( + name: "PeopleCount", + table: "reservations", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "用餐人数。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "reservations", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "reservations", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CustomerPhone", + table: "reservations", + type: "character varying(32)", + maxLength: 32, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldComment: "联系电话。"); + + migrationBuilder.AlterColumn( + name: "CustomerName", + table: "reservations", + type: "character varying(64)", + maxLength: 64, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldComment: "客户姓名。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "reservations", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "reservations", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "CheckedInAt", + table: "reservations", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "实际签到时间。"); + + migrationBuilder.AlterColumn( + name: "CheckInCode", + table: "reservations", + type: "character varying(32)", + maxLength: 32, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldNullable: true, + oldComment: "核销码/到店码。"); + + migrationBuilder.AlterColumn( + name: "CancelledAt", + table: "reservations", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "取消时间。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "reservations", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "refund_requests", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "refund_requests", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "refund_requests", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "refund_requests", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "退款状态。"); + + migrationBuilder.AlterColumn( + name: "ReviewNotes", + table: "refund_requests", + type: "character varying(256)", + maxLength: 256, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true, + oldComment: "审核备注。"); + + migrationBuilder.AlterColumn( + name: "RequestedAt", + table: "refund_requests", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "用户提交时间。"); + + migrationBuilder.AlterColumn( + name: "RefundNo", + table: "refund_requests", + type: "character varying(32)", + maxLength: 32, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldComment: "退款单号。"); + + migrationBuilder.AlterColumn( + name: "Reason", + table: "refund_requests", + type: "character varying(256)", + maxLength: 256, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldComment: "申请原因。"); + + migrationBuilder.AlterColumn( + name: "ProcessedAt", + table: "refund_requests", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "审核完成时间。"); + + migrationBuilder.AlterColumn( + name: "OrderId", + table: "refund_requests", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "关联订单标识。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "refund_requests", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "refund_requests", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "refund_requests", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "refund_requests", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Amount", + table: "refund_requests", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldComment: "申请金额。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "refund_requests", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "queue_tickets", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "queue_tickets", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TicketNumber", + table: "queue_tickets", + type: "character varying(32)", + maxLength: 32, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldComment: "排队编号。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "queue_tickets", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "queue_tickets", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "状态。"); + + migrationBuilder.AlterColumn( + name: "Remark", + table: "queue_tickets", + type: "character varying(256)", + maxLength: 256, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true, + oldComment: "备注。"); + + migrationBuilder.AlterColumn( + name: "PartySize", + table: "queue_tickets", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "就餐人数。"); + + migrationBuilder.AlterColumn( + name: "ExpiredAt", + table: "queue_tickets", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "过号时间。"); + + migrationBuilder.AlterColumn( + name: "EstimatedWaitMinutes", + table: "queue_tickets", + type: "integer", + nullable: true, + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true, + oldComment: "预计等待分钟。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "queue_tickets", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "queue_tickets", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "queue_tickets", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "queue_tickets", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "CancelledAt", + table: "queue_tickets", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "取消时间。"); + + migrationBuilder.AlterColumn( + name: "CalledAt", + table: "queue_tickets", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "叫号时间。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "queue_tickets", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "promotion_campaigns", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "promotion_campaigns", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "promotion_campaigns", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "promotion_campaigns", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "活动状态。"); + + migrationBuilder.AlterColumn( + name: "StartAt", + table: "promotion_campaigns", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "开始时间。"); + + migrationBuilder.AlterColumn( + name: "RulesJson", + table: "promotion_campaigns", + type: "text", + nullable: false, + oldClrType: typeof(string), + oldType: "text", + oldComment: "活动规则 JSON。"); + + migrationBuilder.AlterColumn( + name: "PromotionType", + table: "promotion_campaigns", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "活动类型。"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "promotion_campaigns", + type: "character varying(128)", + maxLength: 128, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldComment: "活动名称。"); + + migrationBuilder.AlterColumn( + name: "EndAt", + table: "promotion_campaigns", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "结束时间。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "promotion_campaigns", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "promotion_campaigns", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "promotion_campaigns", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "promotion_campaigns", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Budget", + table: "promotion_campaigns", + type: "numeric", + nullable: true, + oldClrType: typeof(decimal), + oldType: "numeric", + oldNullable: true, + oldComment: "预算金额。"); + + migrationBuilder.AlterColumn( + name: "BannerUrl", + table: "promotion_campaigns", + type: "character varying(512)", + maxLength: 512, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldNullable: true, + oldComment: "营销素材(如 banner)。"); + + migrationBuilder.AlterColumn( + name: "AudienceDescription", + table: "promotion_campaigns", + type: "character varying(512)", + maxLength: 512, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldNullable: true, + oldComment: "目标人群描述。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "promotion_campaigns", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "products", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "products", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "Unit", + table: "products", + type: "character varying(16)", + maxLength: 16, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(16)", + oldMaxLength: 16, + oldNullable: true, + oldComment: "售卖单位(份/杯等)。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "products", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "Subtitle", + table: "products", + type: "character varying(256)", + maxLength: 256, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true, + oldComment: "副标题/卖点。"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "products", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属门店。"); + + migrationBuilder.AlterColumn( + name: "StockQuantity", + table: "products", + type: "integer", + nullable: true, + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true, + oldComment: "库存数量(可选)。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "products", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "商品状态。"); + + migrationBuilder.AlterColumn( + name: "SpuCode", + table: "products", + type: "character varying(32)", + maxLength: 32, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldComment: "商品编码。"); + + migrationBuilder.AlterColumn( + name: "Price", + table: "products", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldComment: "现价。"); + + migrationBuilder.AlterColumn( + name: "OriginalPrice", + table: "products", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: true, + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldNullable: true, + oldComment: "原价。"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "products", + type: "character varying(128)", + maxLength: 128, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldComment: "商品名称。"); + + migrationBuilder.AlterColumn( + name: "MaxQuantityPerOrder", + table: "products", + type: "integer", + nullable: true, + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true, + oldComment: "最大每单限购。"); + + migrationBuilder.AlterColumn( + name: "IsFeatured", + table: "products", + type: "boolean", + nullable: false, + oldClrType: typeof(bool), + oldType: "boolean", + oldComment: "是否热门推荐。"); + + migrationBuilder.AlterColumn( + name: "GalleryImages", + table: "products", + type: "character varying(1024)", + maxLength: 1024, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(1024)", + oldMaxLength: 1024, + oldNullable: true, + oldComment: "Gallery 图片逗号分隔。"); + + migrationBuilder.AlterColumn( + name: "EnablePickup", + table: "products", + type: "boolean", + nullable: false, + oldClrType: typeof(bool), + oldType: "boolean", + oldComment: "支持自提。"); + + migrationBuilder.AlterColumn( + name: "EnableDineIn", + table: "products", + type: "boolean", + nullable: false, + oldClrType: typeof(bool), + oldType: "boolean", + oldComment: "支持堂食。"); + + migrationBuilder.AlterColumn( + name: "EnableDelivery", + table: "products", + type: "boolean", + nullable: false, + oldClrType: typeof(bool), + oldType: "boolean", + oldComment: "支持配送。"); + + migrationBuilder.AlterColumn( + name: "Description", + table: "products", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "商品描述。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "products", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "products", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "products", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "products", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "CoverImage", + table: "products", + type: "character varying(256)", + maxLength: 256, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true, + oldComment: "主图。"); + + migrationBuilder.AlterColumn( + name: "CategoryId", + table: "products", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属分类。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "products", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "Weight", + table: "product_skus", + type: "numeric(10,3)", + precision: 10, + scale: 3, + nullable: true, + oldClrType: typeof(decimal), + oldType: "numeric(10,3)", + oldPrecision: 10, + oldScale: 3, + oldNullable: true, + oldComment: "重量(千克)。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "product_skus", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "product_skus", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "product_skus", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "StockQuantity", + table: "product_skus", + type: "integer", + nullable: true, + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true, + oldComment: "可售库存。"); + + migrationBuilder.AlterColumn( + name: "SkuCode", + table: "product_skus", + type: "character varying(32)", + maxLength: 32, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldComment: "SKU 编码。"); + + migrationBuilder.AlterColumn( + name: "ProductId", + table: "product_skus", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属商品标识。"); + + migrationBuilder.AlterColumn( + name: "Price", + table: "product_skus", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldComment: "售价。"); + + migrationBuilder.AlterColumn( + name: "OriginalPrice", + table: "product_skus", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: true, + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldNullable: true, + oldComment: "原价。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "product_skus", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "product_skus", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "product_skus", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "product_skus", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Barcode", + table: "product_skus", + type: "character varying(64)", + maxLength: 64, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true, + oldComment: "条形码。"); + + migrationBuilder.AlterColumn( + name: "AttributesJson", + table: "product_skus", + type: "text", + nullable: false, + oldClrType: typeof(string), + oldType: "text", + oldComment: "规格属性 JSON(记录选项 ID)。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "product_skus", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "WeekdaysJson", + table: "product_pricing_rules", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "生效星期(JSON 数组)。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "product_pricing_rules", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "product_pricing_rules", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "product_pricing_rules", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "StartTime", + table: "product_pricing_rules", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "生效开始时间。"); + + migrationBuilder.AlterColumn( + name: "RuleType", + table: "product_pricing_rules", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "策略类型。"); + + migrationBuilder.AlterColumn( + name: "ProductId", + table: "product_pricing_rules", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属商品。"); + + migrationBuilder.AlterColumn( + name: "Price", + table: "product_pricing_rules", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldComment: "特殊价格。"); + + migrationBuilder.AlterColumn( + name: "EndTime", + table: "product_pricing_rules", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "生效结束时间。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "product_pricing_rules", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "product_pricing_rules", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "product_pricing_rules", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "product_pricing_rules", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "ConditionsJson", + table: "product_pricing_rules", + type: "text", + nullable: false, + oldClrType: typeof(string), + oldType: "text", + oldComment: "条件描述(JSON),如会员等级、渠道等。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "product_pricing_rules", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "Url", + table: "product_media_assets", + type: "character varying(512)", + maxLength: 512, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldComment: "媒资链接。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "product_media_assets", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "product_media_assets", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "product_media_assets", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "SortOrder", + table: "product_media_assets", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "排序。"); + + migrationBuilder.AlterColumn( + name: "ProductId", + table: "product_media_assets", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "商品标识。"); + + migrationBuilder.AlterColumn( + name: "MediaType", + table: "product_media_assets", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "媒体类型。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "product_media_assets", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "product_media_assets", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "product_media_assets", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "product_media_assets", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Caption", + table: "product_media_assets", + type: "character varying(256)", + maxLength: 256, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true, + oldComment: "描述或标题。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "product_media_assets", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "product_categories", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "product_categories", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "product_categories", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "product_categories", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属门店。"); + + migrationBuilder.AlterColumn( + name: "SortOrder", + table: "product_categories", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "排序值。"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "product_categories", + type: "character varying(64)", + maxLength: 64, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldComment: "分类名称。"); + + migrationBuilder.AlterColumn( + name: "IsEnabled", + table: "product_categories", + type: "boolean", + nullable: false, + oldClrType: typeof(bool), + oldType: "boolean", + oldComment: "是否启用。"); + + migrationBuilder.AlterColumn( + name: "Description", + table: "product_categories", + type: "character varying(256)", + maxLength: 256, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true, + oldComment: "分类描述。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "product_categories", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "product_categories", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "product_categories", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "product_categories", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "product_categories", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "product_attribute_options", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "product_attribute_options", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "product_attribute_options", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "SortOrder", + table: "product_attribute_options", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "排序。"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "product_attribute_options", + type: "character varying(64)", + maxLength: 64, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldComment: "选项名称。"); + + migrationBuilder.AlterColumn( + name: "IsDefault", + table: "product_attribute_options", + type: "boolean", + nullable: false, + oldClrType: typeof(bool), + oldType: "boolean", + oldComment: "是否默认选中。"); + + migrationBuilder.AlterColumn( + name: "ExtraPrice", + table: "product_attribute_options", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: true, + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldNullable: true, + oldComment: "附加价格。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "product_attribute_options", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "product_attribute_options", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "product_attribute_options", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "product_attribute_options", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "AttributeGroupId", + table: "product_attribute_options", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属规格组。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "product_attribute_options", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "product_attribute_groups", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "product_attribute_groups", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "product_attribute_groups", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "product_attribute_groups", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "关联门店,可为空表示所有门店共享。"); + + migrationBuilder.AlterColumn( + name: "SortOrder", + table: "product_attribute_groups", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "显示排序。"); + + migrationBuilder.AlterColumn( + name: "SelectionType", + table: "product_attribute_groups", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "选择类型(单选/多选)。"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "product_attribute_groups", + type: "character varying(64)", + maxLength: 64, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldComment: "分组名称,例如“辣度”“份量”。"); + + migrationBuilder.AlterColumn( + name: "IsRequired", + table: "product_attribute_groups", + type: "boolean", + nullable: false, + oldClrType: typeof(bool), + oldType: "boolean", + oldComment: "是否必选。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "product_attribute_groups", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "product_attribute_groups", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "product_attribute_groups", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "product_attribute_groups", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "product_attribute_groups", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "product_addon_options", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "product_addon_options", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "product_addon_options", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "SortOrder", + table: "product_addon_options", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "排序。"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "product_addon_options", + type: "character varying(64)", + maxLength: 64, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldComment: "选项名称。"); + + migrationBuilder.AlterColumn( + name: "IsDefault", + table: "product_addon_options", + type: "boolean", + nullable: false, + oldClrType: typeof(bool), + oldType: "boolean", + oldComment: "是否默认选项。"); + + migrationBuilder.AlterColumn( + name: "ExtraPrice", + table: "product_addon_options", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: true, + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldNullable: true, + oldComment: "附加价格。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "product_addon_options", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "product_addon_options", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "product_addon_options", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "product_addon_options", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "AddonGroupId", + table: "product_addon_options", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属加料分组。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "product_addon_options", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "product_addon_groups", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "product_addon_groups", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "product_addon_groups", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "SortOrder", + table: "product_addon_groups", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "排序值。"); + + migrationBuilder.AlterColumn( + name: "SelectionType", + table: "product_addon_groups", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "选择类型。"); + + migrationBuilder.AlterColumn( + name: "ProductId", + table: "product_addon_groups", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属商品。"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "product_addon_groups", + type: "character varying(64)", + maxLength: 64, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldComment: "分组名称。"); + + migrationBuilder.AlterColumn( + name: "MinSelect", + table: "product_addon_groups", + type: "integer", + nullable: true, + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true, + oldComment: "最小选择数量。"); + + migrationBuilder.AlterColumn( + name: "MaxSelect", + table: "product_addon_groups", + type: "integer", + nullable: true, + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true, + oldComment: "最大选择数量。"); + + migrationBuilder.AlterColumn( + name: "IsRequired", + table: "product_addon_groups", + type: "boolean", + nullable: false, + oldClrType: typeof(bool), + oldType: "boolean", + oldComment: "是否必选。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "product_addon_groups", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "product_addon_groups", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "product_addon_groups", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "product_addon_groups", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "product_addon_groups", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "payment_refund_records", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "payment_refund_records", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "payment_refund_records", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "payment_refund_records", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "退款状态。"); + + migrationBuilder.AlterColumn( + name: "RequestedAt", + table: "payment_refund_records", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "退款请求时间。"); + + migrationBuilder.AlterColumn( + name: "PaymentRecordId", + table: "payment_refund_records", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "原支付记录标识。"); + + migrationBuilder.AlterColumn( + name: "Payload", + table: "payment_refund_records", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "渠道返回的原始数据 JSON。"); + + migrationBuilder.AlterColumn( + name: "OrderId", + table: "payment_refund_records", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "关联订单标识。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "payment_refund_records", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "payment_refund_records", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "payment_refund_records", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "payment_refund_records", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "CompletedAt", + table: "payment_refund_records", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "完成时间。"); + + migrationBuilder.AlterColumn( + name: "ChannelRefundId", + table: "payment_refund_records", + type: "character varying(64)", + maxLength: 64, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true, + oldComment: "渠道退款流水号。"); + + migrationBuilder.AlterColumn( + name: "Amount", + table: "payment_refund_records", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldComment: "退款金额。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "payment_refund_records", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "payment_records", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "payment_records", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TradeNo", + table: "payment_records", + type: "character varying(64)", + maxLength: 64, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true, + oldComment: "平台交易号。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "payment_records", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "payment_records", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "支付状态。"); + + migrationBuilder.AlterColumn( + name: "Remark", + table: "payment_records", + type: "character varying(256)", + maxLength: 256, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true, + oldComment: "错误/备注。"); + + migrationBuilder.AlterColumn( + name: "Payload", + table: "payment_records", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "原始回调内容。"); + + migrationBuilder.AlterColumn( + name: "PaidAt", + table: "payment_records", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "支付完成时间。"); + + migrationBuilder.AlterColumn( + name: "OrderId", + table: "payment_records", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "关联订单。"); + + migrationBuilder.AlterColumn( + name: "Method", + table: "payment_records", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "支付方式。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "payment_records", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "payment_records", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "payment_records", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "payment_records", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "ChannelTransactionId", + table: "payment_records", + type: "character varying(64)", + maxLength: 64, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true, + oldComment: "第三方渠道单号。"); + + migrationBuilder.AlterColumn( + name: "Amount", + table: "payment_records", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldComment: "支付金额。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "payment_records", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "orders", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "orders", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "orders", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "TableNo", + table: "orders", + type: "character varying(32)", + maxLength: 32, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldNullable: true, + oldComment: "就餐桌号。"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "orders", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "门店。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "orders", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "当前状态。"); + + migrationBuilder.AlterColumn( + name: "ReservationId", + table: "orders", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "预约 ID。"); + + migrationBuilder.AlterColumn( + name: "Remark", + table: "orders", + type: "character varying(512)", + maxLength: 512, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldNullable: true, + oldComment: "备注。"); + + migrationBuilder.AlterColumn( + name: "QueueNumber", + table: "orders", + type: "character varying(32)", + maxLength: 32, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldNullable: true, + oldComment: "排队号(如有)。"); + + migrationBuilder.AlterColumn( + name: "PaymentStatus", + table: "orders", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "支付状态。"); + + migrationBuilder.AlterColumn( + name: "PayableAmount", + table: "orders", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldComment: "应付金额。"); + + migrationBuilder.AlterColumn( + name: "PaidAt", + table: "orders", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "支付时间。"); + + migrationBuilder.AlterColumn( + name: "PaidAmount", + table: "orders", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldComment: "实付金额。"); + + migrationBuilder.AlterColumn( + name: "OrderNo", + table: "orders", + type: "character varying(32)", + maxLength: 32, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldComment: "订单号。"); + + migrationBuilder.AlterColumn( + name: "ItemsAmount", + table: "orders", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldComment: "商品总额。"); + + migrationBuilder.AlterColumn( + name: "FinishedAt", + table: "orders", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "完成时间。"); + + migrationBuilder.AlterColumn( + name: "DiscountAmount", + table: "orders", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldComment: "优惠金额。"); + + migrationBuilder.AlterColumn( + name: "DeliveryType", + table: "orders", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "履约类型。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "orders", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "orders", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CustomerPhone", + table: "orders", + type: "character varying(32)", + maxLength: 32, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldNullable: true, + oldComment: "顾客手机号。"); + + migrationBuilder.AlterColumn( + name: "CustomerName", + table: "orders", + type: "character varying(64)", + maxLength: 64, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true, + oldComment: "顾客姓名。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "orders", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "orders", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Channel", + table: "orders", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "下单渠道。"); + + migrationBuilder.AlterColumn( + name: "CancelledAt", + table: "orders", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "取消时间。"); + + migrationBuilder.AlterColumn( + name: "CancelReason", + table: "orders", + type: "character varying(256)", + maxLength: 256, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true, + oldComment: "取消原因。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "orders", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "order_status_histories", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "order_status_histories", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "order_status_histories", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "order_status_histories", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "变更后的状态。"); + + migrationBuilder.AlterColumn( + name: "OrderId", + table: "order_status_histories", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "订单标识。"); + + migrationBuilder.AlterColumn( + name: "OperatorId", + table: "order_status_histories", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "操作人标识(可为空表示系统)。"); + + migrationBuilder.AlterColumn( + name: "OccurredAt", + table: "order_status_histories", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "发生时间。"); + + migrationBuilder.AlterColumn( + name: "Notes", + table: "order_status_histories", + type: "character varying(256)", + maxLength: 256, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true, + oldComment: "备注信息。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "order_status_histories", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "order_status_histories", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "order_status_histories", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "order_status_histories", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "order_status_histories", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "order_items", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "order_items", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "UnitPrice", + table: "order_items", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldComment: "单价。"); + + migrationBuilder.AlterColumn( + name: "Unit", + table: "order_items", + type: "character varying(16)", + maxLength: 16, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(16)", + oldMaxLength: 16, + oldNullable: true, + oldComment: "单位。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "order_items", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "SubTotal", + table: "order_items", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldComment: "小计。"); + + migrationBuilder.AlterColumn( + name: "SkuName", + table: "order_items", + type: "character varying(128)", + maxLength: 128, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldNullable: true, + oldComment: "SKU/规格描述。"); + + migrationBuilder.AlterColumn( + name: "Quantity", + table: "order_items", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "数量。"); + + migrationBuilder.AlterColumn( + name: "ProductName", + table: "order_items", + type: "character varying(128)", + maxLength: 128, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldComment: "商品名称。"); + + migrationBuilder.AlterColumn( + name: "ProductId", + table: "order_items", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "商品 ID。"); + + migrationBuilder.AlterColumn( + name: "OrderId", + table: "order_items", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "订单 ID。"); + + migrationBuilder.AlterColumn( + name: "DiscountAmount", + table: "order_items", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldComment: "折扣金额。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "order_items", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "order_items", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "order_items", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "order_items", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "AttributesJson", + table: "order_items", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "自定义属性 JSON。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "order_items", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UserId", + table: "navigation_requests", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "用户 ID。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "navigation_requests", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "navigation_requests", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "navigation_requests", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "TargetApp", + table: "navigation_requests", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "跳转的地图应用。"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "navigation_requests", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "门店 ID。"); + + migrationBuilder.AlterColumn( + name: "RequestedAt", + table: "navigation_requests", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "请求时间。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "navigation_requests", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "navigation_requests", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "navigation_requests", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "navigation_requests", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Channel", + table: "navigation_requests", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "来源通道(小程序、H5 等)。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "navigation_requests", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "WindowStart", + table: "metric_snapshots", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "统计时间窗口开始。"); + + migrationBuilder.AlterColumn( + name: "WindowEnd", + table: "metric_snapshots", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "统计时间窗口结束。"); + + migrationBuilder.AlterColumn( + name: "Value", + table: "metric_snapshots", + type: "numeric(18,4)", + precision: 18, + scale: 4, + nullable: false, + oldClrType: typeof(decimal), + oldType: "numeric(18,4)", + oldPrecision: 18, + oldScale: 4, + oldComment: "数值。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "metric_snapshots", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "metric_snapshots", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "metric_snapshots", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "MetricDefinitionId", + table: "metric_snapshots", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "指标定义 ID。"); + + migrationBuilder.AlterColumn( + name: "DimensionKey", + table: "metric_snapshots", + type: "character varying(256)", + maxLength: 256, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldComment: "维度键(JSON)。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "metric_snapshots", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "metric_snapshots", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "metric_snapshots", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "metric_snapshots", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "metric_snapshots", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "metric_definitions", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "metric_definitions", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "metric_definitions", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "metric_definitions", + type: "character varying(128)", + maxLength: 128, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldComment: "指标名称。"); + + migrationBuilder.AlterColumn( + name: "DimensionsJson", + table: "metric_definitions", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "维度描述 JSON。"); + + migrationBuilder.AlterColumn( + name: "Description", + table: "metric_definitions", + type: "character varying(512)", + maxLength: 512, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldNullable: true, + oldComment: "说明。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "metric_definitions", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "metric_definitions", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DefaultAggregation", + table: "metric_definitions", + type: "character varying(32)", + maxLength: 32, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldComment: "默认聚合方式。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "metric_definitions", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "metric_definitions", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Code", + table: "metric_definitions", + type: "character varying(64)", + maxLength: 64, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldComment: "指标编码。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "metric_definitions", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "metric_alert_rules", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "metric_alert_rules", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "metric_alert_rules", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "Severity", + table: "metric_alert_rules", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "告警级别。"); + + migrationBuilder.AlterColumn( + name: "NotificationChannels", + table: "metric_alert_rules", + type: "character varying(256)", + maxLength: 256, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldComment: "通知渠道。"); + + migrationBuilder.AlterColumn( + name: "MetricDefinitionId", + table: "metric_alert_rules", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "关联指标。"); + + migrationBuilder.AlterColumn( + name: "Enabled", + table: "metric_alert_rules", + type: "boolean", + nullable: false, + oldClrType: typeof(bool), + oldType: "boolean", + oldComment: "是否启用。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "metric_alert_rules", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "metric_alert_rules", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "metric_alert_rules", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "metric_alert_rules", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "ConditionJson", + table: "metric_alert_rules", + type: "text", + nullable: false, + oldClrType: typeof(string), + oldType: "text", + oldComment: "触发条件 JSON。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "metric_alert_rules", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "merchants", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "merchants", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "merchants", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "TaxNumber", + table: "merchants", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "税号/统一社会信用代码。"); + + migrationBuilder.AlterColumn( + name: "SupportEmail", + table: "merchants", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "客服邮箱。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "merchants", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "入驻状态。"); + + migrationBuilder.AlterColumn( + name: "ServicePhone", + table: "merchants", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "客服电话。"); + + migrationBuilder.AlterColumn( + name: "ReviewRemarks", + table: "merchants", + type: "character varying(512)", + maxLength: 512, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldNullable: true, + oldComment: "审核备注或驳回原因。"); + + migrationBuilder.AlterColumn( + name: "Province", + table: "merchants", + type: "character varying(64)", + maxLength: 64, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true, + oldComment: "所在省份。"); + + migrationBuilder.AlterColumn( + name: "Longitude", + table: "merchants", + type: "double precision", + nullable: true, + oldClrType: typeof(double), + oldType: "double precision", + oldNullable: true, + oldComment: "经度信息。"); + + migrationBuilder.AlterColumn( + name: "LogoUrl", + table: "merchants", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "品牌 Logo。"); + + migrationBuilder.AlterColumn( + name: "LegalPerson", + table: "merchants", + type: "character varying(64)", + maxLength: 64, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true, + oldComment: "法人或负责人姓名。"); + + migrationBuilder.AlterColumn( + name: "Latitude", + table: "merchants", + type: "double precision", + nullable: true, + oldClrType: typeof(double), + oldType: "double precision", + oldNullable: true, + oldComment: "纬度信息。"); + + migrationBuilder.AlterColumn( + name: "LastReviewedAt", + table: "merchants", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次审核时间。"); + + migrationBuilder.AlterColumn( + name: "JoinedAt", + table: "merchants", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "入驻时间。"); + + migrationBuilder.AlterColumn( + name: "District", + table: "merchants", + type: "character varying(64)", + maxLength: 64, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true, + oldComment: "所在区县。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "merchants", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "merchants", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "merchants", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "merchants", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "ContactPhone", + table: "merchants", + type: "character varying(32)", + maxLength: 32, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldComment: "联系电话。"); + + migrationBuilder.AlterColumn( + name: "ContactEmail", + table: "merchants", + type: "character varying(128)", + maxLength: 128, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldNullable: true, + oldComment: "联系邮箱。"); + + migrationBuilder.AlterColumn( + name: "City", + table: "merchants", + type: "character varying(64)", + maxLength: 64, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true, + oldComment: "所在城市。"); + + migrationBuilder.AlterColumn( + name: "Category", + table: "merchants", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "品牌所属品类,如火锅、咖啡等。"); + + migrationBuilder.AlterColumn( + name: "BusinessLicenseNumber", + table: "merchants", + type: "character varying(64)", + maxLength: 64, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true, + oldComment: "营业执照号。"); + + migrationBuilder.AlterColumn( + name: "BusinessLicenseImageUrl", + table: "merchants", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "营业执照扫描件地址。"); + + migrationBuilder.AlterColumn( + name: "BrandName", + table: "merchants", + type: "character varying(128)", + maxLength: 128, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldComment: "品牌名称(对外展示)。"); + + migrationBuilder.AlterColumn( + name: "BrandAlias", + table: "merchants", + type: "character varying(64)", + maxLength: 64, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true, + oldComment: "品牌简称或别名。"); + + migrationBuilder.AlterColumn( + name: "Address", + table: "merchants", + type: "character varying(256)", + maxLength: 256, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true, + oldComment: "详细地址。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "merchants", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "merchant_staff", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "merchant_staff", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "merchant_staff", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "merchant_staff", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "可选的关联门店 ID。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "merchant_staff", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "员工状态。"); + + migrationBuilder.AlterColumn( + name: "RoleType", + table: "merchant_staff", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "员工角色类型。"); + + migrationBuilder.AlterColumn( + name: "Phone", + table: "merchant_staff", + type: "character varying(32)", + maxLength: 32, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldComment: "手机号。"); + + migrationBuilder.AlterColumn( + name: "PermissionsJson", + table: "merchant_staff", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "自定义权限(JSON)。"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "merchant_staff", + type: "character varying(64)", + maxLength: 64, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldComment: "员工姓名。"); + + migrationBuilder.AlterColumn( + name: "MerchantId", + table: "merchant_staff", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属商户标识。"); + + migrationBuilder.AlterColumn( + name: "IdentityUserId", + table: "merchant_staff", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "登录账号 ID(指向统一身份体系)。"); + + migrationBuilder.AlterColumn( + name: "Email", + table: "merchant_staff", + type: "character varying(128)", + maxLength: 128, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldNullable: true, + oldComment: "邮箱地址。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "merchant_staff", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "merchant_staff", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "merchant_staff", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "merchant_staff", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "merchant_staff", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "merchant_documents", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "merchant_documents", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "merchant_documents", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "merchant_documents", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "审核状态。"); + + migrationBuilder.AlterColumn( + name: "Remarks", + table: "merchant_documents", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "审核备注或驳回原因。"); + + migrationBuilder.AlterColumn( + name: "MerchantId", + table: "merchant_documents", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属商户标识。"); + + migrationBuilder.AlterColumn( + name: "IssuedAt", + table: "merchant_documents", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "签发日期。"); + + migrationBuilder.AlterColumn( + name: "FileUrl", + table: "merchant_documents", + type: "character varying(512)", + maxLength: 512, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldComment: "证照文件链接。"); + + migrationBuilder.AlterColumn( + name: "ExpiresAt", + table: "merchant_documents", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "到期日期。"); + + migrationBuilder.AlterColumn( + name: "DocumentType", + table: "merchant_documents", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "证照类型。"); + + migrationBuilder.AlterColumn( + name: "DocumentNumber", + table: "merchant_documents", + type: "character varying(64)", + maxLength: 64, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true, + oldComment: "证照编号。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "merchant_documents", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "merchant_documents", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "merchant_documents", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "merchant_documents", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "merchant_documents", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "merchant_contracts", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "merchant_contracts", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TerminationReason", + table: "merchant_contracts", + type: "character varying(256)", + maxLength: 256, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true, + oldComment: "终止原因。"); + + migrationBuilder.AlterColumn( + name: "TerminatedAt", + table: "merchant_contracts", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "终止时间。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "merchant_contracts", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "merchant_contracts", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "合同状态。"); + + migrationBuilder.AlterColumn( + name: "StartDate", + table: "merchant_contracts", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "合同开始时间。"); + + migrationBuilder.AlterColumn( + name: "SignedAt", + table: "merchant_contracts", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "签署时间。"); + + migrationBuilder.AlterColumn( + name: "MerchantId", + table: "merchant_contracts", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属商户标识。"); + + migrationBuilder.AlterColumn( + name: "FileUrl", + table: "merchant_contracts", + type: "character varying(512)", + maxLength: 512, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldComment: "合同文件存储地址。"); + + migrationBuilder.AlterColumn( + name: "EndDate", + table: "merchant_contracts", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "合同结束时间。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "merchant_contracts", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "merchant_contracts", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "merchant_contracts", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "merchant_contracts", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "ContractNumber", + table: "merchant_contracts", + type: "character varying(64)", + maxLength: 64, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldComment: "合同编号。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "merchant_contracts", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "member_tiers", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "member_tiers", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "member_tiers", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "SortOrder", + table: "member_tiers", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "排序值。"); + + migrationBuilder.AlterColumn( + name: "RequiredGrowth", + table: "member_tiers", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "所需成长值。"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "member_tiers", + type: "character varying(64)", + maxLength: 64, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldComment: "等级名称。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "member_tiers", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "member_tiers", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "member_tiers", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "member_tiers", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "BenefitsJson", + table: "member_tiers", + type: "text", + nullable: false, + oldClrType: typeof(string), + oldType: "text", + oldComment: "等级权益(JSON)。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "member_tiers", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UserId", + table: "member_profiles", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "用户标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "member_profiles", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "member_profiles", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "member_profiles", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "member_profiles", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "会员状态。"); + + migrationBuilder.AlterColumn( + name: "PointsBalance", + table: "member_profiles", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "会员积分余额。"); + + migrationBuilder.AlterColumn( + name: "Nickname", + table: "member_profiles", + type: "character varying(64)", + maxLength: 64, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true, + oldComment: "昵称。"); + + migrationBuilder.AlterColumn( + name: "Mobile", + table: "member_profiles", + type: "character varying(32)", + maxLength: 32, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldComment: "手机号。"); + + migrationBuilder.AlterColumn( + name: "MemberTierId", + table: "member_profiles", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "当前会员等级 ID。"); + + migrationBuilder.AlterColumn( + name: "JoinedAt", + table: "member_profiles", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "注册时间。"); + + migrationBuilder.AlterColumn( + name: "GrowthValue", + table: "member_profiles", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "成长值/经验值。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "member_profiles", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "member_profiles", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "member_profiles", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "member_profiles", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "BirthDate", + table: "member_profiles", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "生日。"); + + migrationBuilder.AlterColumn( + name: "AvatarUrl", + table: "member_profiles", + type: "character varying(256)", + maxLength: 256, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true, + oldComment: "头像。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "member_profiles", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "member_point_ledgers", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "member_point_ledgers", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "member_point_ledgers", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "SourceId", + table: "member_point_ledgers", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "来源 ID(订单、活动等)。"); + + migrationBuilder.AlterColumn( + name: "Reason", + table: "member_point_ledgers", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "变动原因。"); + + migrationBuilder.AlterColumn( + name: "OccurredAt", + table: "member_point_ledgers", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "发生时间。"); + + migrationBuilder.AlterColumn( + name: "MemberId", + table: "member_point_ledgers", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "会员标识。"); + + migrationBuilder.AlterColumn( + name: "ExpireAt", + table: "member_point_ledgers", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "过期时间(如适用)。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "member_point_ledgers", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "member_point_ledgers", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "member_point_ledgers", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "member_point_ledgers", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "ChangeAmount", + table: "member_point_ledgers", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "变动数量,可为负值。"); + + migrationBuilder.AlterColumn( + name: "BalanceAfterChange", + table: "member_point_ledgers", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "变动后余额。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "member_point_ledgers", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "member_growth_logs", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "member_growth_logs", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "member_growth_logs", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "OccurredAt", + table: "member_growth_logs", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "发生时间。"); + + migrationBuilder.AlterColumn( + name: "Notes", + table: "member_growth_logs", + type: "character varying(256)", + maxLength: 256, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true, + oldComment: "备注。"); + + migrationBuilder.AlterColumn( + name: "MemberId", + table: "member_growth_logs", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "会员标识。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "member_growth_logs", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "member_growth_logs", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CurrentValue", + table: "member_growth_logs", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "当前成长值。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "member_growth_logs", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "member_growth_logs", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "ChangeValue", + table: "member_growth_logs", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "变动数量。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "member_growth_logs", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "map_locations", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "map_locations", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "map_locations", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "map_locations", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "关联门店 ID,可空表示独立 POI。"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "map_locations", + type: "character varying(128)", + maxLength: 128, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldComment: "名称。"); + + migrationBuilder.AlterColumn( + name: "Longitude", + table: "map_locations", + type: "double precision", + nullable: false, + oldClrType: typeof(double), + oldType: "double precision", + oldComment: "经度。"); + + migrationBuilder.AlterColumn( + name: "Latitude", + table: "map_locations", + type: "double precision", + nullable: false, + oldClrType: typeof(double), + oldType: "double precision", + oldComment: "纬度。"); + + migrationBuilder.AlterColumn( + name: "Landmark", + table: "map_locations", + type: "character varying(128)", + maxLength: 128, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldNullable: true, + oldComment: "打车/导航落点描述。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "map_locations", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "map_locations", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "map_locations", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "map_locations", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Address", + table: "map_locations", + type: "character varying(256)", + maxLength: 256, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldComment: "地址。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "map_locations", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "inventory_items", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "inventory_items", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "inventory_items", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "inventory_items", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "门店标识。"); + + migrationBuilder.AlterColumn( + name: "SafetyStock", + table: "inventory_items", + type: "integer", + nullable: true, + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true, + oldComment: "安全库存阈值。"); + + migrationBuilder.AlterColumn( + name: "QuantityReserved", + table: "inventory_items", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "已锁定库存(订单占用)。"); + + migrationBuilder.AlterColumn( + name: "QuantityOnHand", + table: "inventory_items", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "可用库存。"); + + migrationBuilder.AlterColumn( + name: "ProductSkuId", + table: "inventory_items", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "SKU 标识。"); + + migrationBuilder.AlterColumn( + name: "Location", + table: "inventory_items", + type: "character varying(64)", + maxLength: 64, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true, + oldComment: "储位或仓位信息。"); + + migrationBuilder.AlterColumn( + name: "ExpireDate", + table: "inventory_items", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "过期日期。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "inventory_items", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "inventory_items", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "inventory_items", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "inventory_items", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "BatchNumber", + table: "inventory_items", + type: "character varying(64)", + maxLength: 64, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true, + oldComment: "批次编号,可为空表示混批。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "inventory_items", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "inventory_batches", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "inventory_batches", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "inventory_batches", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "inventory_batches", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "门店标识。"); + + migrationBuilder.AlterColumn( + name: "RemainingQuantity", + table: "inventory_batches", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "剩余数量。"); + + migrationBuilder.AlterColumn( + name: "Quantity", + table: "inventory_batches", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "入库数量。"); + + migrationBuilder.AlterColumn( + name: "ProductionDate", + table: "inventory_batches", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "生产日期。"); + + migrationBuilder.AlterColumn( + name: "ProductSkuId", + table: "inventory_batches", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "SKU 标识。"); + + migrationBuilder.AlterColumn( + name: "ExpireDate", + table: "inventory_batches", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "过期日期。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "inventory_batches", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "inventory_batches", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "inventory_batches", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "inventory_batches", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "BatchNumber", + table: "inventory_batches", + type: "character varying(64)", + maxLength: 64, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldComment: "批次编号。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "inventory_batches", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "inventory_adjustments", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "inventory_adjustments", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "inventory_adjustments", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "Reason", + table: "inventory_adjustments", + type: "character varying(256)", + maxLength: 256, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true, + oldComment: "原因说明。"); + + migrationBuilder.AlterColumn( + name: "Quantity", + table: "inventory_adjustments", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "调整数量,正数增加,负数减少。"); + + migrationBuilder.AlterColumn( + name: "OperatorId", + table: "inventory_adjustments", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "操作人标识。"); + + migrationBuilder.AlterColumn( + name: "OccurredAt", + table: "inventory_adjustments", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "发生时间。"); + + migrationBuilder.AlterColumn( + name: "InventoryItemId", + table: "inventory_adjustments", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "对应的库存记录标识。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "inventory_adjustments", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "inventory_adjustments", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "inventory_adjustments", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "inventory_adjustments", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "AdjustmentType", + table: "inventory_adjustments", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "调整类型。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "inventory_adjustments", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UserId", + table: "group_participants", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "用户标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "group_participants", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "group_participants", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "group_participants", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "group_participants", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "参与状态。"); + + migrationBuilder.AlterColumn( + name: "OrderId", + table: "group_participants", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "对应订单标识。"); + + migrationBuilder.AlterColumn( + name: "JoinedAt", + table: "group_participants", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "参与时间。"); + + migrationBuilder.AlterColumn( + name: "GroupOrderId", + table: "group_participants", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "拼单活动标识。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "group_participants", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "group_participants", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "group_participants", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "group_participants", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "group_participants", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "group_orders", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "group_orders", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "group_orders", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "TargetCount", + table: "group_orders", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "成团需要的人数。"); + + migrationBuilder.AlterColumn( + name: "SucceededAt", + table: "group_orders", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "成团时间。"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "group_orders", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "门店标识。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "group_orders", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "拼团状态。"); + + migrationBuilder.AlterColumn( + name: "StartAt", + table: "group_orders", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "开始时间。"); + + migrationBuilder.AlterColumn( + name: "ProductId", + table: "group_orders", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "关联商品或套餐。"); + + migrationBuilder.AlterColumn( + name: "LeaderUserId", + table: "group_orders", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "团长用户 ID。"); + + migrationBuilder.AlterColumn( + name: "GroupPrice", + table: "group_orders", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldComment: "拼团价格。"); + + migrationBuilder.AlterColumn( + name: "GroupOrderNo", + table: "group_orders", + type: "character varying(32)", + maxLength: 32, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldComment: "拼单编号。"); + + migrationBuilder.AlterColumn( + name: "EndAt", + table: "group_orders", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "结束时间。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "group_orders", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "group_orders", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CurrentCount", + table: "group_orders", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "当前已参与人数。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "group_orders", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "group_orders", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "CancelledAt", + table: "group_orders", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "取消时间。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "group_orders", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "delivery_orders", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "delivery_orders", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "delivery_orders", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "delivery_orders", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "状态。"); + + migrationBuilder.AlterColumn( + name: "ProviderOrderId", + table: "delivery_orders", + type: "character varying(64)", + maxLength: 64, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true, + oldComment: "第三方配送单号。"); + + migrationBuilder.AlterColumn( + name: "Provider", + table: "delivery_orders", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "配送服务商。"); + + migrationBuilder.AlterColumn( + name: "PickedUpAt", + table: "delivery_orders", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "取餐时间。"); + + migrationBuilder.AlterColumn( + name: "FailureReason", + table: "delivery_orders", + type: "character varying(256)", + maxLength: 256, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true, + oldComment: "异常原因。"); + + migrationBuilder.AlterColumn( + name: "DispatchedAt", + table: "delivery_orders", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "下发时间。"); + + migrationBuilder.AlterColumn( + name: "DeliveryFee", + table: "delivery_orders", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: true, + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldNullable: true, + oldComment: "配送费。"); + + migrationBuilder.AlterColumn( + name: "DeliveredAt", + table: "delivery_orders", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "完成时间。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "delivery_orders", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "delivery_orders", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "delivery_orders", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "delivery_orders", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "CourierPhone", + table: "delivery_orders", + type: "character varying(32)", + maxLength: 32, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldNullable: true, + oldComment: "骑手电话。"); + + migrationBuilder.AlterColumn( + name: "CourierName", + table: "delivery_orders", + type: "character varying(64)", + maxLength: 64, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldNullable: true, + oldComment: "骑手姓名。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "delivery_orders", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "delivery_events", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "delivery_events", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "delivery_events", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "Payload", + table: "delivery_events", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "原始数据 JSON。"); + + migrationBuilder.AlterColumn( + name: "OccurredAt", + table: "delivery_events", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "发生时间。"); + + migrationBuilder.AlterColumn( + name: "Message", + table: "delivery_events", + type: "character varying(256)", + maxLength: 256, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldComment: "事件描述。"); + + migrationBuilder.AlterColumn( + name: "EventType", + table: "delivery_events", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "事件类型。"); + + migrationBuilder.AlterColumn( + name: "DeliveryOrderId", + table: "delivery_events", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "配送单标识。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "delivery_events", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "delivery_events", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "delivery_events", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "delivery_events", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "delivery_events", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UserId", + table: "coupons", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "归属用户。"); + + migrationBuilder.AlterColumn( + name: "UsedAt", + table: "coupons", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "使用时间。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "coupons", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "coupons", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "coupons", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "coupons", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "状态。"); + + migrationBuilder.AlterColumn( + name: "OrderId", + table: "coupons", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "订单 ID(已使用时记录)。"); + + migrationBuilder.AlterColumn( + name: "IssuedAt", + table: "coupons", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "发放时间。"); + + migrationBuilder.AlterColumn( + name: "ExpireAt", + table: "coupons", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "到期时间。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "coupons", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "coupons", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "coupons", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "coupons", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "CouponTemplateId", + table: "coupons", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "模板标识。"); + + migrationBuilder.AlterColumn( + name: "Code", + table: "coupons", + type: "character varying(32)", + maxLength: 32, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldComment: "券码或序列号。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "coupons", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "Value", + table: "coupon_templates", + type: "numeric", + nullable: false, + oldClrType: typeof(decimal), + oldType: "numeric", + oldComment: "面值或折扣额度。"); + + migrationBuilder.AlterColumn( + name: "ValidTo", + table: "coupon_templates", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "可用结束时间。"); + + migrationBuilder.AlterColumn( + name: "ValidFrom", + table: "coupon_templates", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "可用开始时间。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "coupon_templates", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "coupon_templates", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TotalQuantity", + table: "coupon_templates", + type: "integer", + nullable: true, + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true, + oldComment: "总发放数量上限。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "coupon_templates", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "StoreScopeJson", + table: "coupon_templates", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "适用门店 ID 集合(JSON)。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "coupon_templates", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "状态。"); + + migrationBuilder.AlterColumn( + name: "RelativeValidDays", + table: "coupon_templates", + type: "integer", + nullable: true, + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true, + oldComment: "有效天数(相对发放时间)。"); + + migrationBuilder.AlterColumn( + name: "ProductScopeJson", + table: "coupon_templates", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "适用品类或商品范围(JSON)。"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "coupon_templates", + type: "character varying(128)", + maxLength: 128, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldComment: "模板名称。"); + + migrationBuilder.AlterColumn( + name: "MinimumSpend", + table: "coupon_templates", + type: "numeric", + nullable: true, + oldClrType: typeof(decimal), + oldType: "numeric", + oldNullable: true, + oldComment: "最低消费门槛。"); + + migrationBuilder.AlterColumn( + name: "DiscountCap", + table: "coupon_templates", + type: "numeric", + nullable: true, + oldClrType: typeof(decimal), + oldType: "numeric", + oldNullable: true, + oldComment: "折扣上限(针对折扣券)。"); + + migrationBuilder.AlterColumn( + name: "Description", + table: "coupon_templates", + type: "character varying(512)", + maxLength: 512, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldNullable: true, + oldComment: "备注。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "coupon_templates", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "coupon_templates", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "coupon_templates", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "coupon_templates", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "CouponType", + table: "coupon_templates", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "券类型。"); + + migrationBuilder.AlterColumn( + name: "ClaimedQuantity", + table: "coupon_templates", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "已领取数量。"); + + migrationBuilder.AlterColumn( + name: "ChannelsJson", + table: "coupon_templates", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "发放渠道(JSON)。"); + + migrationBuilder.AlterColumn( + name: "AllowStack", + table: "coupon_templates", + type: "boolean", + nullable: false, + oldClrType: typeof(bool), + oldType: "boolean", + oldComment: "是否允许叠加其他优惠。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "coupon_templates", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UserId", + table: "community_reactions", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "用户 ID。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "community_reactions", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "community_reactions", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "community_reactions", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "ReactionType", + table: "community_reactions", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "反应类型。"); + + migrationBuilder.AlterColumn( + name: "ReactedAt", + table: "community_reactions", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "时间戳。"); + + migrationBuilder.AlterColumn( + name: "PostId", + table: "community_reactions", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "动态 ID。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "community_reactions", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "community_reactions", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "community_reactions", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "community_reactions", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "community_reactions", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "community_posts", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "community_posts", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "Title", + table: "community_posts", + type: "character varying(128)", + maxLength: 128, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldNullable: true, + oldComment: "标题。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "community_posts", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "community_posts", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "状态。"); + + migrationBuilder.AlterColumn( + name: "MediaJson", + table: "community_posts", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "媒体资源 JSON。"); + + migrationBuilder.AlterColumn( + name: "LikeCount", + table: "community_posts", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "点赞数。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "community_posts", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "community_posts", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "community_posts", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "community_posts", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Content", + table: "community_posts", + type: "text", + nullable: false, + oldClrType: typeof(string), + oldType: "text", + oldComment: "内容。"); + + migrationBuilder.AlterColumn( + name: "CommentCount", + table: "community_posts", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "评论数。"); + + migrationBuilder.AlterColumn( + name: "AuthorUserId", + table: "community_posts", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "作者用户 ID。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "community_posts", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "community_comments", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "community_comments", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "community_comments", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "PostId", + table: "community_comments", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "动态标识。"); + + migrationBuilder.AlterColumn( + name: "ParentId", + table: "community_comments", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "父级评论 ID。"); + + migrationBuilder.AlterColumn( + name: "IsDeleted", + table: "community_comments", + type: "boolean", + nullable: false, + oldClrType: typeof(bool), + oldType: "boolean", + oldComment: "状态。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "community_comments", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "community_comments", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "community_comments", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "community_comments", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Content", + table: "community_comments", + type: "character varying(512)", + maxLength: 512, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldComment: "评论内容。"); + + migrationBuilder.AlterColumn( + name: "AuthorUserId", + table: "community_comments", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "评论人。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "community_comments", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "ValidationResultJson", + table: "checkout_sessions", + type: "text", + nullable: false, + oldClrType: typeof(string), + oldType: "text", + oldComment: "校验结果明细 JSON。"); + + migrationBuilder.AlterColumn( + name: "UserId", + table: "checkout_sessions", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "用户标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "checkout_sessions", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "checkout_sessions", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "checkout_sessions", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "checkout_sessions", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "门店标识。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "checkout_sessions", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "会话状态。"); + + migrationBuilder.AlterColumn( + name: "SessionToken", + table: "checkout_sessions", + type: "character varying(64)", + maxLength: 64, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldComment: "会话 Token。"); + + migrationBuilder.AlterColumn( + name: "ExpiresAt", + table: "checkout_sessions", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "过期时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "checkout_sessions", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "checkout_sessions", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "checkout_sessions", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "checkout_sessions", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "checkout_sessions", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UserId", + table: "checkin_records", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "用户标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "checkin_records", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "checkin_records", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "checkin_records", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "RewardJson", + table: "checkin_records", + type: "text", + nullable: false, + oldClrType: typeof(string), + oldType: "text", + oldComment: "获得奖励 JSON。"); + + migrationBuilder.AlterColumn( + name: "IsMakeup", + table: "checkin_records", + type: "boolean", + nullable: false, + oldClrType: typeof(bool), + oldType: "boolean", + oldComment: "是否补签。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "checkin_records", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "checkin_records", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "checkin_records", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "checkin_records", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "CheckInDate", + table: "checkin_records", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "签到日期(本地)。"); + + migrationBuilder.AlterColumn( + name: "CheckInCampaignId", + table: "checkin_records", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "活动标识。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "checkin_records", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "checkin_campaigns", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "checkin_campaigns", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "checkin_campaigns", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "checkin_campaigns", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "状态。"); + + migrationBuilder.AlterColumn( + name: "StartDate", + table: "checkin_campaigns", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "开始日期。"); + + migrationBuilder.AlterColumn( + name: "RewardsJson", + table: "checkin_campaigns", + type: "text", + nullable: false, + oldClrType: typeof(string), + oldType: "text", + oldComment: "连签奖励 JSON。"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "checkin_campaigns", + type: "character varying(128)", + maxLength: 128, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldComment: "活动名称。"); + + migrationBuilder.AlterColumn( + name: "EndDate", + table: "checkin_campaigns", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "结束日期。"); + + migrationBuilder.AlterColumn( + name: "Description", + table: "checkin_campaigns", + type: "character varying(512)", + maxLength: 512, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldNullable: true, + oldComment: "活动描述。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "checkin_campaigns", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "checkin_campaigns", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "checkin_campaigns", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "checkin_campaigns", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "AllowMakeupCount", + table: "checkin_campaigns", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "支持补签次数。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "checkin_campaigns", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "chat_sessions", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "chat_sessions", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "chat_sessions", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "StoreId", + table: "chat_sessions", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "所属门店(可空为平台)。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "chat_sessions", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "会话状态。"); + + migrationBuilder.AlterColumn( + name: "StartedAt", + table: "chat_sessions", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "开始时间。"); + + migrationBuilder.AlterColumn( + name: "SessionCode", + table: "chat_sessions", + type: "character varying(64)", + maxLength: 64, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldComment: "会话编号。"); + + migrationBuilder.AlterColumn( + name: "IsBotActive", + table: "chat_sessions", + type: "boolean", + nullable: false, + oldClrType: typeof(bool), + oldType: "boolean", + oldComment: "是否机器人接待中。"); + + migrationBuilder.AlterColumn( + name: "EndedAt", + table: "chat_sessions", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "结束时间。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "chat_sessions", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "chat_sessions", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CustomerUserId", + table: "chat_sessions", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "顾客用户 ID。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "chat_sessions", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "chat_sessions", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "AgentUserId", + table: "chat_sessions", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "当前客服员工 ID。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "chat_sessions", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "chat_messages", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "chat_messages", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "chat_messages", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "SenderUserId", + table: "chat_messages", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "发送方用户 ID。"); + + migrationBuilder.AlterColumn( + name: "SenderType", + table: "chat_messages", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "发送方类型。"); + + migrationBuilder.AlterColumn( + name: "ReadAt", + table: "chat_messages", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "读取时间。"); + + migrationBuilder.AlterColumn( + name: "IsRead", + table: "chat_messages", + type: "boolean", + nullable: false, + oldClrType: typeof(bool), + oldType: "boolean", + oldComment: "是否已读。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "chat_messages", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "chat_messages", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "chat_messages", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "chat_messages", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "ContentType", + table: "chat_messages", + type: "character varying(64)", + maxLength: 64, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldComment: "消息类型(文字/图片/语音等)。"); + + migrationBuilder.AlterColumn( + name: "Content", + table: "chat_messages", + type: "character varying(1024)", + maxLength: 1024, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(1024)", + oldMaxLength: 1024, + oldComment: "消息内容。"); + + migrationBuilder.AlterColumn( + name: "ChatSessionId", + table: "chat_messages", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "会话标识。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "chat_messages", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "cart_items", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "cart_items", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "UnitPrice", + table: "cart_items", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldComment: "单价快照。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "cart_items", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "cart_items", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "状态。"); + + migrationBuilder.AlterColumn( + name: "ShoppingCartId", + table: "cart_items", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属购物车标识。"); + + migrationBuilder.AlterColumn( + name: "Remark", + table: "cart_items", + type: "character varying(256)", + maxLength: 256, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true, + oldComment: "自定义备注(口味要求)。"); + + migrationBuilder.AlterColumn( + name: "Quantity", + table: "cart_items", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "数量。"); + + migrationBuilder.AlterColumn( + name: "ProductSkuId", + table: "cart_items", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "SKU 标识。"); + + migrationBuilder.AlterColumn( + name: "ProductName", + table: "cart_items", + type: "character varying(128)", + maxLength: 128, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldComment: "商品名称快照。"); + + migrationBuilder.AlterColumn( + name: "ProductId", + table: "cart_items", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "商品或 SKU 标识。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "cart_items", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "cart_items", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "cart_items", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "cart_items", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "AttributesJson", + table: "cart_items", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true, + oldComment: "扩展 JSON(规格、加料选项等)。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "cart_items", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "cart_item_addons", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "cart_item_addons", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "cart_item_addons", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "OptionId", + table: "cart_item_addons", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "选项 ID(可对应 ProductAddonOption)。"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "cart_item_addons", + type: "character varying(64)", + maxLength: 64, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldComment: "选项名称。"); + + migrationBuilder.AlterColumn( + name: "ExtraPrice", + table: "cart_item_addons", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldComment: "附加价格。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "cart_item_addons", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "cart_item_addons", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "cart_item_addons", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "cart_item_addons", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "CartItemId", + table: "cart_item_addons", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属购物车条目。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "cart_item_addons", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "affiliate_payouts", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "affiliate_payouts", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "affiliate_payouts", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "affiliate_payouts", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "状态。"); + + migrationBuilder.AlterColumn( + name: "Remarks", + table: "affiliate_payouts", + type: "character varying(256)", + maxLength: 256, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true, + oldComment: "备注。"); + + migrationBuilder.AlterColumn( + name: "Period", + table: "affiliate_payouts", + type: "character varying(32)", + maxLength: 32, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldComment: "结算周期描述。"); + + migrationBuilder.AlterColumn( + name: "PaidAt", + table: "affiliate_payouts", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "打款时间。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "affiliate_payouts", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "affiliate_payouts", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "affiliate_payouts", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "affiliate_payouts", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Amount", + table: "affiliate_payouts", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldComment: "结算金额。"); + + migrationBuilder.AlterColumn( + name: "AffiliatePartnerId", + table: "affiliate_payouts", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "合作伙伴标识。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "affiliate_payouts", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UserId", + table: "affiliate_partners", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "用户 ID(如绑定平台账号)。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "affiliate_partners", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "affiliate_partners", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "affiliate_partners", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "affiliate_partners", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "当前状态。"); + + migrationBuilder.AlterColumn( + name: "Remarks", + table: "affiliate_partners", + type: "character varying(256)", + maxLength: 256, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true, + oldComment: "审核备注。"); + + migrationBuilder.AlterColumn( + name: "Phone", + table: "affiliate_partners", + type: "character varying(32)", + maxLength: 32, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(32)", + oldMaxLength: 32, + oldNullable: true, + oldComment: "联系电话。"); + + migrationBuilder.AlterColumn( + name: "DisplayName", + table: "affiliate_partners", + type: "character varying(64)", + maxLength: 64, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldComment: "昵称或渠道名称。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "affiliate_partners", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "affiliate_partners", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "affiliate_partners", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "affiliate_partners", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "CommissionRate", + table: "affiliate_partners", + type: "numeric", + nullable: false, + oldClrType: typeof(decimal), + oldType: "numeric", + oldComment: "分成比例(0-1)。"); + + migrationBuilder.AlterColumn( + name: "ChannelType", + table: "affiliate_partners", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "渠道类型。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "affiliate_partners", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "affiliate_orders", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "affiliate_orders", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "affiliate_orders", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "affiliate_orders", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "当前状态。"); + + migrationBuilder.AlterColumn( + name: "SettledAt", + table: "affiliate_orders", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "结算完成时间。"); + + migrationBuilder.AlterColumn( + name: "OrderId", + table: "affiliate_orders", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "关联订单。"); + + migrationBuilder.AlterColumn( + name: "OrderAmount", + table: "affiliate_orders", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldComment: "订单金额。"); + + migrationBuilder.AlterColumn( + name: "EstimatedCommission", + table: "affiliate_orders", + type: "numeric(18,2)", + precision: 18, + scale: 2, + nullable: false, + oldClrType: typeof(decimal), + oldType: "numeric(18,2)", + oldPrecision: 18, + oldScale: 2, + oldComment: "预计佣金。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "affiliate_orders", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "affiliate_orders", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "affiliate_orders", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "affiliate_orders", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "BuyerUserId", + table: "affiliate_orders", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "用户 ID。"); + + migrationBuilder.AlterColumn( + name: "AffiliatePartnerId", + table: "affiliate_orders", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "推广人标识。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "affiliate_orders", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + } + } +} diff --git a/src/Infrastructure/TakeoutSaaS.Infrastructure/App/Migrations/TakeoutAppDbContextModelSnapshot.cs b/src/Infrastructure/TakeoutSaaS.Infrastructure/App/Migrations/TakeoutAppDbContextModelSnapshot.cs index d0c482a..50ffaf5 100644 --- a/src/Infrastructure/TakeoutSaaS.Infrastructure/App/Migrations/TakeoutAppDbContextModelSnapshot.cs +++ b/src/Infrastructure/TakeoutSaaS.Infrastructure/App/Migrations/TakeoutAppDbContextModelSnapshot.cs @@ -22,263 +22,3175 @@ namespace TakeoutSaaS.Infrastructure.App.Migrations NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + modelBuilder.Entity("TakeoutSaaS.Domain.Analytics.Entities.MetricAlertRule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("ConditionJson") + .IsRequired() + .HasColumnType("text") + .HasComment("触发条件 JSON。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("Enabled") + .HasColumnType("boolean") + .HasComment("是否启用。"); + + b.Property("MetricDefinitionId") + .HasColumnType("uuid") + .HasComment("关联指标。"); + + b.Property("NotificationChannels") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("通知渠道。"); + + b.Property("Severity") + .HasColumnType("integer") + .HasComment("告警级别。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "MetricDefinitionId", "Severity"); + + b.ToTable("metric_alert_rules", null, t => + { + t.HasComment("指标告警规则。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Analytics.Entities.MetricDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("指标编码。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DefaultAggregation") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("默认聚合方式。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("Description") + .HasMaxLength(512) + .HasColumnType("character varying(512)") + .HasComment("说明。"); + + b.Property("DimensionsJson") + .HasColumnType("text") + .HasComment("维度描述 JSON。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("指标名称。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Code") + .IsUnique(); + + b.ToTable("metric_definitions", null, t => + { + t.HasComment("指标定义,描述可观测的数据点。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Analytics.Entities.MetricSnapshot", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("DimensionKey") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("维度键(JSON)。"); + + b.Property("MetricDefinitionId") + .HasColumnType("uuid") + .HasComment("指标定义 ID。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("Value") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)") + .HasComment("数值。"); + + b.Property("WindowEnd") + .HasColumnType("timestamp with time zone") + .HasComment("统计时间窗口结束。"); + + b.Property("WindowStart") + .HasColumnType("timestamp with time zone") + .HasComment("统计时间窗口开始。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "MetricDefinitionId", "DimensionKey", "WindowStart", "WindowEnd") + .IsUnique(); + + b.ToTable("metric_snapshots", null, t => + { + t.HasComment("指标快照,用于大盘展示。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Coupons.Entities.Coupon", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("券码或序列号。"); + + b.Property("CouponTemplateId") + .HasColumnType("uuid") + .HasComment("模板标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("ExpireAt") + .HasColumnType("timestamp with time zone") + .HasComment("到期时间。"); + + b.Property("IssuedAt") + .HasColumnType("timestamp with time zone") + .HasComment("发放时间。"); + + b.Property("OrderId") + .HasColumnType("uuid") + .HasComment("订单 ID(已使用时记录)。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("UsedAt") + .HasColumnType("timestamp with time zone") + .HasComment("使用时间。"); + + b.Property("UserId") + .HasColumnType("uuid") + .HasComment("归属用户。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Code") + .IsUnique(); + + b.ToTable("coupons", null, t => + { + t.HasComment("用户领取的券。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Coupons.Entities.CouponTemplate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AllowStack") + .HasColumnType("boolean") + .HasComment("是否允许叠加其他优惠。"); + + b.Property("ChannelsJson") + .HasColumnType("text") + .HasComment("发放渠道(JSON)。"); + + b.Property("ClaimedQuantity") + .HasColumnType("integer") + .HasComment("已领取数量。"); + + b.Property("CouponType") + .HasColumnType("integer") + .HasComment("券类型。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("Description") + .HasMaxLength(512) + .HasColumnType("character varying(512)") + .HasComment("备注。"); + + b.Property("DiscountCap") + .HasColumnType("numeric") + .HasComment("折扣上限(针对折扣券)。"); + + b.Property("MinimumSpend") + .HasColumnType("numeric") + .HasComment("最低消费门槛。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("模板名称。"); + + b.Property("ProductScopeJson") + .HasColumnType("text") + .HasComment("适用品类或商品范围(JSON)。"); + + b.Property("RelativeValidDays") + .HasColumnType("integer") + .HasComment("有效天数(相对发放时间)。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("状态。"); + + b.Property("StoreScopeJson") + .HasColumnType("text") + .HasComment("适用门店 ID 集合(JSON)。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("TotalQuantity") + .HasColumnType("integer") + .HasComment("总发放数量上限。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("ValidFrom") + .HasColumnType("timestamp with time zone") + .HasComment("可用开始时间。"); + + b.Property("ValidTo") + .HasColumnType("timestamp with time zone") + .HasComment("可用结束时间。"); + + b.Property("Value") + .HasColumnType("numeric") + .HasComment("面值或折扣额度。"); + + b.HasKey("Id"); + + b.ToTable("coupon_templates", null, t => + { + t.HasComment("优惠券模板。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Coupons.Entities.PromotionCampaign", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AudienceDescription") + .HasMaxLength(512) + .HasColumnType("character varying(512)") + .HasComment("目标人群描述。"); + + b.Property("BannerUrl") + .HasMaxLength(512) + .HasColumnType("character varying(512)") + .HasComment("营销素材(如 banner)。"); + + b.Property("Budget") + .HasColumnType("numeric") + .HasComment("预算金额。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("EndAt") + .HasColumnType("timestamp with time zone") + .HasComment("结束时间。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("活动名称。"); + + b.Property("PromotionType") + .HasColumnType("integer") + .HasComment("活动类型。"); + + b.Property("RulesJson") + .IsRequired() + .HasColumnType("text") + .HasComment("活动规则 JSON。"); + + b.Property("StartAt") + .HasColumnType("timestamp with time zone") + .HasComment("开始时间。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("活动状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.ToTable("promotion_campaigns", null, t => + { + t.HasComment("营销活动配置。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.CustomerService.Entities.ChatMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("ChatSessionId") + .HasColumnType("uuid") + .HasComment("会话标识。"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("character varying(1024)") + .HasComment("消息内容。"); + + b.Property("ContentType") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("消息类型(文字/图片/语音等)。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("IsRead") + .HasColumnType("boolean") + .HasComment("是否已读。"); + + b.Property("ReadAt") + .HasColumnType("timestamp with time zone") + .HasComment("读取时间。"); + + b.Property("SenderType") + .HasColumnType("integer") + .HasComment("发送方类型。"); + + b.Property("SenderUserId") + .HasColumnType("uuid") + .HasComment("发送方用户 ID。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "ChatSessionId", "CreatedAt"); + + b.ToTable("chat_messages", null, t => + { + t.HasComment("会话消息。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.CustomerService.Entities.ChatSession", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AgentUserId") + .HasColumnType("uuid") + .HasComment("当前客服员工 ID。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("CustomerUserId") + .HasColumnType("uuid") + .HasComment("顾客用户 ID。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("EndedAt") + .HasColumnType("timestamp with time zone") + .HasComment("结束时间。"); + + b.Property("IsBotActive") + .HasColumnType("boolean") + .HasComment("是否机器人接待中。"); + + b.Property("SessionCode") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("会话编号。"); + + b.Property("StartedAt") + .HasColumnType("timestamp with time zone") + .HasComment("开始时间。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("会话状态。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("所属门店(可空为平台)。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "SessionCode") + .IsUnique(); + + b.ToTable("chat_sessions", null, t => + { + t.HasComment("客服会话。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.CustomerService.Entities.SupportTicket", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AssignedAgentId") + .HasColumnType("uuid") + .HasComment("指派的客服。"); + + b.Property("ClosedAt") + .HasColumnType("timestamp with time zone") + .HasComment("关闭时间。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("CustomerUserId") + .HasColumnType("uuid") + .HasComment("客户用户 ID。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text") + .HasComment("工单详情。"); + + b.Property("OrderId") + .HasColumnType("uuid") + .HasComment("关联订单(如有)。"); + + b.Property("Priority") + .HasColumnType("integer") + .HasComment("优先级。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("状态。"); + + b.Property("Subject") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("工单主题。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("TicketNo") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("工单编号。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "TicketNo") + .IsUnique(); + + b.ToTable("support_tickets", null, t => + { + t.HasComment("客服工单。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.CustomerService.Entities.TicketComment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AttachmentsJson") + .HasColumnType("text") + .HasComment("附件 JSON。"); + + b.Property("AuthorUserId") + .HasColumnType("uuid") + .HasComment("评论人 ID。"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("character varying(1024)") + .HasComment("评论内容。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("IsInternal") + .HasColumnType("boolean") + .HasComment("是否内部备注。"); + + b.Property("SupportTicketId") + .HasColumnType("uuid") + .HasComment("工单标识。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "SupportTicketId"); + + b.ToTable("ticket_comments", null, t => + { + t.HasComment("工单评论/流转记录。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Deliveries.Entities.DeliveryEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("DeliveryOrderId") + .HasColumnType("uuid") + .HasComment("配送单标识。"); + + b.Property("EventType") + .HasColumnType("integer") + .HasComment("事件类型。"); + + b.Property("Message") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("事件描述。"); + + b.Property("OccurredAt") + .HasColumnType("timestamp with time zone") + .HasComment("发生时间。"); + + b.Property("Payload") + .HasColumnType("text") + .HasComment("原始数据 JSON。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "DeliveryOrderId", "EventType"); + + b.ToTable("delivery_events", null, t => + { + t.HasComment("配送状态事件流水。"); + }); + }); + modelBuilder.Entity("TakeoutSaaS.Domain.Deliveries.Entities.DeliveryOrder", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); b.Property("CourierName") .HasMaxLength(64) - .HasColumnType("character varying(64)"); + .HasColumnType("character varying(64)") + .HasComment("骑手姓名。"); b.Property("CourierPhone") .HasMaxLength(32) - .HasColumnType("character varying(32)"); + .HasColumnType("character varying(32)") + .HasComment("骑手电话。"); b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); b.Property("CreatedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); b.Property("DeletedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); b.Property("DeletedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); b.Property("DeliveredAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("完成时间。"); b.Property("DeliveryFee") .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); + .HasColumnType("numeric(18,2)") + .HasComment("配送费。"); b.Property("DispatchedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("下发时间。"); b.Property("FailureReason") .HasMaxLength(256) - .HasColumnType("character varying(256)"); + .HasColumnType("character varying(256)") + .HasComment("异常原因。"); b.Property("OrderId") .HasColumnType("uuid"); b.Property("PickedUpAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("取餐时间。"); b.Property("Provider") - .HasColumnType("integer"); + .HasColumnType("integer") + .HasComment("配送服务商。"); b.Property("ProviderOrderId") .HasMaxLength(64) - .HasColumnType("character varying(64)"); + .HasColumnType("character varying(64)") + .HasComment("第三方配送单号。"); b.Property("Status") - .HasColumnType("integer"); + .HasColumnType("integer") + .HasComment("状态。"); b.Property("TenantId") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); b.Property("UpdatedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); b.HasKey("Id"); b.HasIndex("TenantId", "OrderId") .IsUnique(); - b.ToTable("delivery_orders", (string)null); + b.ToTable("delivery_orders", null, t => + { + t.HasComment("配送单。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Distribution.Entities.AffiliateOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AffiliatePartnerId") + .HasColumnType("uuid") + .HasComment("推广人标识。"); + + b.Property("BuyerUserId") + .HasColumnType("uuid") + .HasComment("用户 ID。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("EstimatedCommission") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("预计佣金。"); + + b.Property("OrderAmount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("订单金额。"); + + b.Property("OrderId") + .HasColumnType("uuid") + .HasComment("关联订单。"); + + b.Property("SettledAt") + .HasColumnType("timestamp with time zone") + .HasComment("结算完成时间。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("当前状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "AffiliatePartnerId", "OrderId") + .IsUnique(); + + b.ToTable("affiliate_orders", null, t => + { + t.HasComment("分销订单记录。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Distribution.Entities.AffiliatePartner", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("ChannelType") + .HasColumnType("integer") + .HasComment("渠道类型。"); + + b.Property("CommissionRate") + .HasColumnType("numeric") + .HasComment("分成比例(0-1)。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("昵称或渠道名称。"); + + b.Property("Phone") + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("联系电话。"); + + b.Property("Remarks") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("审核备注。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("当前状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("UserId") + .HasColumnType("uuid") + .HasComment("用户 ID(如绑定平台账号)。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "DisplayName"); + + b.ToTable("affiliate_partners", null, t => + { + t.HasComment("分销/推广合作伙伴。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Distribution.Entities.AffiliatePayout", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AffiliatePartnerId") + .HasColumnType("uuid") + .HasComment("合作伙伴标识。"); + + b.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("结算金额。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("PaidAt") + .HasColumnType("timestamp with time zone") + .HasComment("打款时间。"); + + b.Property("Period") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("结算周期描述。"); + + b.Property("Remarks") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("备注。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "AffiliatePartnerId", "Period") + .IsUnique(); + + b.ToTable("affiliate_payouts", null, t => + { + t.HasComment("佣金结算记录。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Engagement.Entities.CheckInCampaign", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AllowMakeupCount") + .HasColumnType("integer") + .HasComment("支持补签次数。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("Description") + .HasMaxLength(512) + .HasColumnType("character varying(512)") + .HasComment("活动描述。"); + + b.Property("EndDate") + .HasColumnType("timestamp with time zone") + .HasComment("结束日期。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("活动名称。"); + + b.Property("RewardsJson") + .IsRequired() + .HasColumnType("text") + .HasComment("连签奖励 JSON。"); + + b.Property("StartDate") + .HasColumnType("timestamp with time zone") + .HasComment("开始日期。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Name"); + + b.ToTable("checkin_campaigns", null, t => + { + t.HasComment("签到活动配置。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Engagement.Entities.CheckInRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CheckInCampaignId") + .HasColumnType("uuid") + .HasComment("活动标识。"); + + b.Property("CheckInDate") + .HasColumnType("timestamp with time zone") + .HasComment("签到日期(本地)。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("IsMakeup") + .HasColumnType("boolean") + .HasComment("是否补签。"); + + b.Property("RewardJson") + .IsRequired() + .HasColumnType("text") + .HasComment("获得奖励 JSON。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("UserId") + .HasColumnType("uuid") + .HasComment("用户标识。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "CheckInCampaignId", "UserId", "CheckInDate") + .IsUnique(); + + b.ToTable("checkin_records", null, t => + { + t.HasComment("用户签到记录。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Engagement.Entities.CommunityComment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AuthorUserId") + .HasColumnType("uuid") + .HasComment("评论人。"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("character varying(512)") + .HasComment("评论内容。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("IsDeleted") + .HasColumnType("boolean") + .HasComment("状态。"); + + b.Property("ParentId") + .HasColumnType("uuid") + .HasComment("父级评论 ID。"); + + b.Property("PostId") + .HasColumnType("uuid") + .HasComment("动态标识。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "PostId", "CreatedAt"); + + b.ToTable("community_comments", null, t => + { + t.HasComment("社区评论。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Engagement.Entities.CommunityPost", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AuthorUserId") + .HasColumnType("uuid") + .HasComment("作者用户 ID。"); + + b.Property("CommentCount") + .HasColumnType("integer") + .HasComment("评论数。"); + + b.Property("Content") + .IsRequired() + .HasColumnType("text") + .HasComment("内容。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("LikeCount") + .HasColumnType("integer") + .HasComment("点赞数。"); + + b.Property("MediaJson") + .HasColumnType("text") + .HasComment("媒体资源 JSON。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("Title") + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("标题。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "AuthorUserId", "CreatedAt"); + + b.ToTable("community_posts", null, t => + { + t.HasComment("社区动态。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Engagement.Entities.CommunityReaction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("PostId") + .HasColumnType("uuid") + .HasComment("动态 ID。"); + + b.Property("ReactedAt") + .HasColumnType("timestamp with time zone") + .HasComment("时间戳。"); + + b.Property("ReactionType") + .HasColumnType("integer") + .HasComment("反应类型。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("UserId") + .HasColumnType("uuid") + .HasComment("用户 ID。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "PostId", "UserId") + .IsUnique(); + + b.ToTable("community_reactions", null, t => + { + t.HasComment("社区互动反馈。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.GroupBuying.Entities.GroupOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CancelledAt") + .HasColumnType("timestamp with time zone") + .HasComment("取消时间。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("CurrentCount") + .HasColumnType("integer") + .HasComment("当前已参与人数。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("EndAt") + .HasColumnType("timestamp with time zone") + .HasComment("结束时间。"); + + b.Property("GroupOrderNo") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("拼单编号。"); + + b.Property("GroupPrice") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("拼团价格。"); + + b.Property("LeaderUserId") + .HasColumnType("uuid") + .HasComment("团长用户 ID。"); + + b.Property("ProductId") + .HasColumnType("uuid") + .HasComment("关联商品或套餐。"); + + b.Property("StartAt") + .HasColumnType("timestamp with time zone") + .HasComment("开始时间。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("拼团状态。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("门店标识。"); + + b.Property("SucceededAt") + .HasColumnType("timestamp with time zone") + .HasComment("成团时间。"); + + b.Property("TargetCount") + .HasColumnType("integer") + .HasComment("成团需要的人数。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "GroupOrderNo") + .IsUnique(); + + b.ToTable("group_orders", null, t => + { + t.HasComment("拼单活动。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.GroupBuying.Entities.GroupParticipant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("GroupOrderId") + .HasColumnType("uuid") + .HasComment("拼单活动标识。"); + + b.Property("JoinedAt") + .HasColumnType("timestamp with time zone") + .HasComment("参与时间。"); + + b.Property("OrderId") + .HasColumnType("uuid") + .HasComment("对应订单标识。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("参与状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("UserId") + .HasColumnType("uuid") + .HasComment("用户标识。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "GroupOrderId", "UserId") + .IsUnique(); + + b.ToTable("group_participants", null, t => + { + t.HasComment("拼单参与者。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Inventory.Entities.InventoryAdjustment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AdjustmentType") + .HasColumnType("integer") + .HasComment("调整类型。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("InventoryItemId") + .HasColumnType("uuid") + .HasComment("对应的库存记录标识。"); + + b.Property("OccurredAt") + .HasColumnType("timestamp with time zone") + .HasComment("发生时间。"); + + b.Property("OperatorId") + .HasColumnType("uuid") + .HasComment("操作人标识。"); + + b.Property("Quantity") + .HasColumnType("integer") + .HasComment("调整数量,正数增加,负数减少。"); + + b.Property("Reason") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("原因说明。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "InventoryItemId", "OccurredAt"); + + b.ToTable("inventory_adjustments", null, t => + { + t.HasComment("库存调整记录。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Inventory.Entities.InventoryBatch", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("BatchNumber") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("批次编号。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("ExpireDate") + .HasColumnType("timestamp with time zone") + .HasComment("过期日期。"); + + b.Property("ProductSkuId") + .HasColumnType("uuid") + .HasComment("SKU 标识。"); + + b.Property("ProductionDate") + .HasColumnType("timestamp with time zone") + .HasComment("生产日期。"); + + b.Property("Quantity") + .HasColumnType("integer") + .HasComment("入库数量。"); + + b.Property("RemainingQuantity") + .HasColumnType("integer") + .HasComment("剩余数量。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("门店标识。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId", "ProductSkuId", "BatchNumber") + .IsUnique(); + + b.ToTable("inventory_batches", null, t => + { + t.HasComment("SKU 批次信息。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Inventory.Entities.InventoryItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("BatchNumber") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("批次编号,可为空表示混批。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("ExpireDate") + .HasColumnType("timestamp with time zone") + .HasComment("过期日期。"); + + b.Property("Location") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("储位或仓位信息。"); + + b.Property("ProductSkuId") + .HasColumnType("uuid") + .HasComment("SKU 标识。"); + + b.Property("QuantityOnHand") + .HasColumnType("integer") + .HasComment("可用库存。"); + + b.Property("QuantityReserved") + .HasColumnType("integer") + .HasComment("已锁定库存(订单占用)。"); + + b.Property("SafetyStock") + .HasColumnType("integer") + .HasComment("安全库存阈值。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("门店标识。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId", "ProductSkuId", "BatchNumber"); + + b.ToTable("inventory_items", null, t => + { + t.HasComment("SKU 在门店的库存信息。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Membership.Entities.MemberGrowthLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("ChangeValue") + .HasColumnType("integer") + .HasComment("变动数量。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("CurrentValue") + .HasColumnType("integer") + .HasComment("当前成长值。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("MemberId") + .HasColumnType("uuid") + .HasComment("会员标识。"); + + b.Property("Notes") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("备注。"); + + b.Property("OccurredAt") + .HasColumnType("timestamp with time zone") + .HasComment("发生时间。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "MemberId", "OccurredAt"); + + b.ToTable("member_growth_logs", null, t => + { + t.HasComment("成长值变动日志。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Membership.Entities.MemberPointLedger", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("BalanceAfterChange") + .HasColumnType("integer") + .HasComment("变动后余额。"); + + b.Property("ChangeAmount") + .HasColumnType("integer") + .HasComment("变动数量,可为负值。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("ExpireAt") + .HasColumnType("timestamp with time zone") + .HasComment("过期时间(如适用)。"); + + b.Property("MemberId") + .HasColumnType("uuid") + .HasComment("会员标识。"); + + b.Property("OccurredAt") + .HasColumnType("timestamp with time zone") + .HasComment("发生时间。"); + + b.Property("Reason") + .HasColumnType("integer") + .HasComment("变动原因。"); + + b.Property("SourceId") + .HasColumnType("uuid") + .HasComment("来源 ID(订单、活动等)。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "MemberId", "OccurredAt"); + + b.ToTable("member_point_ledgers", null, t => + { + t.HasComment("积分变动流水。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Membership.Entities.MemberProfile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AvatarUrl") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("头像。"); + + b.Property("BirthDate") + .HasColumnType("timestamp with time zone") + .HasComment("生日。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("GrowthValue") + .HasColumnType("integer") + .HasComment("成长值/经验值。"); + + b.Property("JoinedAt") + .HasColumnType("timestamp with time zone") + .HasComment("注册时间。"); + + b.Property("MemberTierId") + .HasColumnType("uuid") + .HasComment("当前会员等级 ID。"); + + b.Property("Mobile") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("手机号。"); + + b.Property("Nickname") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("昵称。"); + + b.Property("PointsBalance") + .HasColumnType("integer") + .HasComment("会员积分余额。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("会员状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("UserId") + .HasColumnType("uuid") + .HasComment("用户标识。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Mobile") + .IsUnique(); + + b.ToTable("member_profiles", null, t => + { + t.HasComment("会员档案。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Membership.Entities.MemberTier", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("BenefitsJson") + .IsRequired() + .HasColumnType("text") + .HasComment("等级权益(JSON)。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("等级名称。"); + + b.Property("RequiredGrowth") + .HasColumnType("integer") + .HasComment("所需成长值。"); + + b.Property("SortOrder") + .HasColumnType("integer") + .HasComment("排序值。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Name") + .IsUnique(); + + b.ToTable("member_tiers", null, t => + { + t.HasComment("会员等级定义。"); + }); }); modelBuilder.Entity("TakeoutSaaS.Domain.Merchants.Entities.Merchant", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); b.Property("Address") .HasMaxLength(256) - .HasColumnType("character varying(256)"); + .HasColumnType("character varying(256)") + .HasComment("详细地址。"); b.Property("BrandAlias") .HasMaxLength(64) - .HasColumnType("character varying(64)"); + .HasColumnType("character varying(64)") + .HasComment("品牌简称或别名。"); b.Property("BrandName") .IsRequired() .HasMaxLength(128) - .HasColumnType("character varying(128)"); + .HasColumnType("character varying(128)") + .HasComment("品牌名称(对外展示)。"); + + b.Property("BusinessLicenseImageUrl") + .HasColumnType("text") + .HasComment("营业执照扫描件地址。"); b.Property("BusinessLicenseNumber") .HasMaxLength(64) - .HasColumnType("character varying(64)"); + .HasColumnType("character varying(64)") + .HasComment("营业执照号。"); + + b.Property("Category") + .HasColumnType("text") + .HasComment("品牌所属品类,如火锅、咖啡等。"); b.Property("City") .HasMaxLength(64) - .HasColumnType("character varying(64)"); + .HasColumnType("character varying(64)") + .HasComment("所在城市。"); b.Property("ContactEmail") .HasMaxLength(128) - .HasColumnType("character varying(128)"); + .HasColumnType("character varying(128)") + .HasComment("联系邮箱。"); b.Property("ContactPhone") .IsRequired() .HasMaxLength(32) - .HasColumnType("character varying(32)"); + .HasColumnType("character varying(32)") + .HasComment("联系电话。"); b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); b.Property("CreatedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); b.Property("DeletedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); b.Property("DeletedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); b.Property("District") .HasMaxLength(64) - .HasColumnType("character varying(64)"); + .HasColumnType("character varying(64)") + .HasComment("所在区县。"); + + b.Property("JoinedAt") + .HasColumnType("timestamp with time zone") + .HasComment("入驻时间。"); + + b.Property("LastReviewedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次审核时间。"); + + b.Property("Latitude") + .HasColumnType("double precision") + .HasComment("纬度信息。"); b.Property("LegalPerson") .HasMaxLength(64) - .HasColumnType("character varying(64)"); + .HasColumnType("character varying(64)") + .HasComment("法人或负责人姓名。"); - b.Property("OnboardedAt") - .HasColumnType("timestamp with time zone"); + b.Property("LogoUrl") + .HasColumnType("text") + .HasComment("品牌 Logo。"); + + b.Property("Longitude") + .HasColumnType("double precision") + .HasComment("经度信息。"); b.Property("Province") .HasMaxLength(64) - .HasColumnType("character varying(64)"); + .HasColumnType("character varying(64)") + .HasComment("所在省份。"); b.Property("ReviewRemarks") .HasMaxLength(512) - .HasColumnType("character varying(512)"); + .HasColumnType("character varying(512)") + .HasComment("审核备注或驳回原因。"); + + b.Property("ServicePhone") + .HasColumnType("text") + .HasComment("客服电话。"); b.Property("Status") - .HasColumnType("integer"); + .HasColumnType("integer") + .HasComment("入驻状态。"); + + b.Property("SupportEmail") + .HasColumnType("text") + .HasComment("客服邮箱。"); + + b.Property("TaxNumber") + .HasColumnType("text") + .HasComment("税号/统一社会信用代码。"); b.Property("TenantId") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); b.Property("UpdatedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); b.HasKey("Id"); b.HasIndex("TenantId"); - b.ToTable("merchants", (string)null); + b.ToTable("merchants", null, t => + { + t.HasComment("商户主体信息,承载入驻和资质审核结果。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Merchants.Entities.MerchantContract", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("ContractNumber") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("合同编号。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("EndDate") + .HasColumnType("timestamp with time zone") + .HasComment("合同结束时间。"); + + b.Property("FileUrl") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("character varying(512)") + .HasComment("合同文件存储地址。"); + + b.Property("MerchantId") + .HasColumnType("uuid") + .HasComment("所属商户标识。"); + + b.Property("SignedAt") + .HasColumnType("timestamp with time zone") + .HasComment("签署时间。"); + + b.Property("StartDate") + .HasColumnType("timestamp with time zone") + .HasComment("合同开始时间。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("合同状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("TerminatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("终止时间。"); + + b.Property("TerminationReason") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("终止原因。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "MerchantId", "ContractNumber") + .IsUnique(); + + b.ToTable("merchant_contracts", null, t => + { + t.HasComment("商户合同记录。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Merchants.Entities.MerchantDocument", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("DocumentNumber") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("证照编号。"); + + b.Property("DocumentType") + .HasColumnType("integer") + .HasComment("证照类型。"); + + b.Property("ExpiresAt") + .HasColumnType("timestamp with time zone") + .HasComment("到期日期。"); + + b.Property("FileUrl") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("character varying(512)") + .HasComment("证照文件链接。"); + + b.Property("IssuedAt") + .HasColumnType("timestamp with time zone") + .HasComment("签发日期。"); + + b.Property("MerchantId") + .HasColumnType("uuid") + .HasComment("所属商户标识。"); + + b.Property("Remarks") + .HasColumnType("text") + .HasComment("审核备注或驳回原因。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("审核状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "MerchantId", "DocumentType"); + + b.ToTable("merchant_documents", null, t => + { + t.HasComment("商户提交的资质或证照材料。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Merchants.Entities.MerchantStaff", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("Email") + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("邮箱地址。"); + + b.Property("IdentityUserId") + .HasColumnType("uuid") + .HasComment("登录账号 ID(指向统一身份体系)。"); + + b.Property("MerchantId") + .HasColumnType("uuid") + .HasComment("所属商户标识。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("员工姓名。"); + + b.Property("PermissionsJson") + .HasColumnType("text") + .HasComment("自定义权限(JSON)。"); + + b.Property("Phone") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("手机号。"); + + b.Property("RoleType") + .HasColumnType("integer") + .HasComment("员工角色类型。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("员工状态。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("可选的关联门店 ID。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "MerchantId", "Phone"); + + b.ToTable("merchant_staff", null, t => + { + t.HasComment("商户员工账号,支持门店维度分配。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Navigation.Entities.MapLocation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("Address") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("地址。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("Landmark") + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("打车/导航落点描述。"); + + b.Property("Latitude") + .HasColumnType("double precision") + .HasComment("纬度。"); + + b.Property("Longitude") + .HasColumnType("double precision") + .HasComment("经度。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("名称。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("关联门店 ID,可空表示独立 POI。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId"); + + b.ToTable("map_locations", null, t => + { + t.HasComment("地图 POI 信息,用于门店定位和推荐。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Navigation.Entities.NavigationRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("Channel") + .HasColumnType("integer") + .HasComment("来源通道(小程序、H5 等)。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("RequestedAt") + .HasColumnType("timestamp with time zone") + .HasComment("请求时间。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("门店 ID。"); + + b.Property("TargetApp") + .HasColumnType("integer") + .HasComment("跳转的地图应用。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("UserId") + .HasColumnType("uuid") + .HasComment("用户 ID。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "UserId", "StoreId", "RequestedAt"); + + b.ToTable("navigation_requests", null, t => + { + t.HasComment("用户发起的导航请求日志。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Ordering.Entities.CartItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AttributesJson") + .HasColumnType("text") + .HasComment("扩展 JSON(规格、加料选项等)。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("ProductId") + .HasColumnType("uuid") + .HasComment("商品或 SKU 标识。"); + + b.Property("ProductName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("商品名称快照。"); + + b.Property("ProductSkuId") + .HasColumnType("uuid") + .HasComment("SKU 标识。"); + + b.Property("Quantity") + .HasColumnType("integer") + .HasComment("数量。"); + + b.Property("Remark") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("自定义备注(口味要求)。"); + + b.Property("ShoppingCartId") + .HasColumnType("uuid") + .HasComment("所属购物车标识。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UnitPrice") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("单价快照。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "ShoppingCartId"); + + b.ToTable("cart_items", null, t => + { + t.HasComment("购物车条目。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Ordering.Entities.CartItemAddon", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CartItemId") + .HasColumnType("uuid") + .HasComment("所属购物车条目。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("ExtraPrice") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("附加价格。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("选项名称。"); + + b.Property("OptionId") + .HasColumnType("uuid") + .HasComment("选项 ID(可对应 ProductAddonOption)。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.ToTable("cart_item_addons", null, t => + { + t.HasComment("购物车条目的加料/附加项。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Ordering.Entities.CheckoutSession", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("ExpiresAt") + .HasColumnType("timestamp with time zone") + .HasComment("过期时间(UTC)。"); + + b.Property("SessionToken") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("会话 Token。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("会话状态。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("门店标识。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("UserId") + .HasColumnType("uuid") + .HasComment("用户标识。"); + + b.Property("ValidationResultJson") + .IsRequired() + .HasColumnType("text") + .HasComment("校验结果明细 JSON。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "SessionToken") + .IsUnique(); + + b.ToTable("checkout_sessions", null, t => + { + t.HasComment("结账会话,记录校验上下文。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Ordering.Entities.ShoppingCart", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("DeliveryPreference") + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("履约方式(堂食/自提/配送)缓存。"); + + b.Property("LastModifiedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次修改时间(UTC)。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("购物车状态,包含正常/锁定。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("门店标识。"); + + b.Property("TableContext") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("桌码或场景标识(扫码点餐)。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("UserId") + .HasColumnType("uuid") + .HasComment("用户标识。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "UserId", "StoreId") + .IsUnique(); + + b.ToTable("shopping_carts", null, t => + { + t.HasComment("用户购物车,按租户/门店隔离。"); + }); }); modelBuilder.Entity("TakeoutSaaS.Domain.Orders.Entities.Order", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); b.Property("CancelReason") .HasMaxLength(256) - .HasColumnType("character varying(256)"); + .HasColumnType("character varying(256)") + .HasComment("取消原因。"); b.Property("CancelledAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("取消时间。"); b.Property("Channel") - .HasColumnType("integer"); + .HasColumnType("integer") + .HasComment("下单渠道。"); b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); b.Property("CreatedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); b.Property("CustomerName") .HasMaxLength(64) - .HasColumnType("character varying(64)"); + .HasColumnType("character varying(64)") + .HasComment("顾客姓名。"); b.Property("CustomerPhone") .HasMaxLength(32) - .HasColumnType("character varying(32)"); + .HasColumnType("character varying(32)") + .HasComment("顾客手机号。"); b.Property("DeletedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); b.Property("DeletedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); b.Property("DeliveryType") - .HasColumnType("integer"); + .HasColumnType("integer") + .HasComment("履约类型。"); b.Property("DiscountAmount") .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); + .HasColumnType("numeric(18,2)") + .HasComment("优惠金额。"); b.Property("FinishedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("完成时间。"); b.Property("ItemsAmount") .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); + .HasColumnType("numeric(18,2)") + .HasComment("商品总额。"); b.Property("OrderNo") .IsRequired() .HasMaxLength(32) - .HasColumnType("character varying(32)"); + .HasColumnType("character varying(32)") + .HasComment("订单号。"); b.Property("PaidAmount") .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); + .HasColumnType("numeric(18,2)") + .HasComment("实付金额。"); b.Property("PaidAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("支付时间。"); b.Property("PayableAmount") .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); + .HasColumnType("numeric(18,2)") + .HasComment("应付金额。"); b.Property("PaymentStatus") - .HasColumnType("integer"); + .HasColumnType("integer") + .HasComment("支付状态。"); b.Property("QueueNumber") .HasMaxLength(32) - .HasColumnType("character varying(32)"); + .HasColumnType("character varying(32)") + .HasComment("排队号(如有)。"); b.Property("Remark") .HasMaxLength(512) - .HasColumnType("character varying(512)"); + .HasColumnType("character varying(512)") + .HasComment("备注。"); b.Property("ReservationId") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("预约 ID。"); b.Property("Status") - .HasColumnType("integer"); + .HasColumnType("integer") + .HasComment("当前状态。"); b.Property("StoreId") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("门店。"); b.Property("TableNo") .HasMaxLength(32) - .HasColumnType("character varying(32)"); + .HasColumnType("character varying(32)") + .HasComment("就餐桌号。"); b.Property("TenantId") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); b.Property("UpdatedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); b.HasKey("Id"); @@ -287,72 +3199,93 @@ namespace TakeoutSaaS.Infrastructure.App.Migrations b.HasIndex("TenantId", "StoreId", "Status"); - b.ToTable("orders", (string)null); + b.ToTable("orders", null, t => + { + t.HasComment("交易订单。"); + }); }); modelBuilder.Entity("TakeoutSaaS.Domain.Orders.Entities.OrderItem", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); b.Property("AttributesJson") - .HasColumnType("text"); + .HasColumnType("text") + .HasComment("自定义属性 JSON。"); b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); b.Property("CreatedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); b.Property("DeletedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); b.Property("DeletedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); b.Property("DiscountAmount") .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); + .HasColumnType("numeric(18,2)") + .HasComment("折扣金额。"); b.Property("OrderId") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("订单 ID。"); b.Property("ProductId") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("商品 ID。"); b.Property("ProductName") .IsRequired() .HasMaxLength(128) - .HasColumnType("character varying(128)"); + .HasColumnType("character varying(128)") + .HasComment("商品名称。"); b.Property("Quantity") - .HasColumnType("integer"); + .HasColumnType("integer") + .HasComment("数量。"); b.Property("SkuName") .HasMaxLength(128) - .HasColumnType("character varying(128)"); + .HasColumnType("character varying(128)") + .HasComment("SKU/规格描述。"); b.Property("SubTotal") .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); + .HasColumnType("numeric(18,2)") + .HasComment("小计。"); b.Property("TenantId") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); b.Property("Unit") .HasMaxLength(16) - .HasColumnType("character varying(16)"); + .HasColumnType("character varying(16)") + .HasComment("单位。"); b.Property("UnitPrice") .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); + .HasColumnType("numeric(18,2)") + .HasComment("单价。"); b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); b.Property("UpdatedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); b.HasKey("Id"); @@ -360,164 +3293,442 @@ namespace TakeoutSaaS.Infrastructure.App.Migrations b.HasIndex("TenantId", "OrderId"); - b.ToTable("order_items", (string)null); + b.ToTable("order_items", null, t => + { + t.HasComment("订单明细。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Orders.Entities.OrderStatusHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("Notes") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("备注信息。"); + + b.Property("OccurredAt") + .HasColumnType("timestamp with time zone") + .HasComment("发生时间。"); + + b.Property("OperatorId") + .HasColumnType("uuid") + .HasComment("操作人标识(可为空表示系统)。"); + + b.Property("OrderId") + .HasColumnType("uuid") + .HasComment("订单标识。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("变更后的状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "OrderId", "OccurredAt"); + + b.ToTable("order_status_histories", null, t => + { + t.HasComment("订单状态流转记录。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Orders.Entities.RefundRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("申请金额。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("OrderId") + .HasColumnType("uuid") + .HasComment("关联订单标识。"); + + b.Property("ProcessedAt") + .HasColumnType("timestamp with time zone") + .HasComment("审核完成时间。"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("申请原因。"); + + b.Property("RefundNo") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("退款单号。"); + + b.Property("RequestedAt") + .HasColumnType("timestamp with time zone") + .HasComment("用户提交时间。"); + + b.Property("ReviewNotes") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("审核备注。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("退款状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "RefundNo") + .IsUnique(); + + b.ToTable("refund_requests", null, t => + { + t.HasComment("售后/退款申请。"); + }); }); modelBuilder.Entity("TakeoutSaaS.Domain.Payments.Entities.PaymentRecord", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); b.Property("Amount") .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); + .HasColumnType("numeric(18,2)") + .HasComment("支付金额。"); b.Property("ChannelTransactionId") .HasMaxLength(64) - .HasColumnType("character varying(64)"); + .HasColumnType("character varying(64)") + .HasComment("第三方渠道单号。"); b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); b.Property("CreatedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); b.Property("DeletedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); b.Property("DeletedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); b.Property("Method") - .HasColumnType("integer"); + .HasColumnType("integer") + .HasComment("支付方式。"); b.Property("OrderId") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("关联订单。"); b.Property("PaidAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("支付完成时间。"); b.Property("Payload") - .HasColumnType("text"); + .HasColumnType("text") + .HasComment("原始回调内容。"); b.Property("Remark") .HasMaxLength(256) - .HasColumnType("character varying(256)"); + .HasColumnType("character varying(256)") + .HasComment("错误/备注。"); b.Property("Status") - .HasColumnType("integer"); + .HasColumnType("integer") + .HasComment("支付状态。"); b.Property("TenantId") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); b.Property("TradeNo") .HasMaxLength(64) - .HasColumnType("character varying(64)"); + .HasColumnType("character varying(64)") + .HasComment("平台交易号。"); b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); b.Property("UpdatedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); b.HasKey("Id"); b.HasIndex("TenantId", "OrderId"); - b.ToTable("payment_records", (string)null); + b.ToTable("payment_records", null, t => + { + t.HasComment("支付流水。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Payments.Entities.PaymentRefundRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("退款金额。"); + + b.Property("ChannelRefundId") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("渠道退款流水号。"); + + b.Property("CompletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("完成时间。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("OrderId") + .HasColumnType("uuid") + .HasComment("关联订单标识。"); + + b.Property("Payload") + .HasColumnType("text") + .HasComment("渠道返回的原始数据 JSON。"); + + b.Property("PaymentRecordId") + .HasColumnType("uuid") + .HasComment("原支付记录标识。"); + + b.Property("RequestedAt") + .HasColumnType("timestamp with time zone") + .HasComment("退款请求时间。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("退款状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "PaymentRecordId"); + + b.ToTable("payment_refund_records", null, t => + { + t.HasComment("支付渠道退款流水。"); + }); }); modelBuilder.Entity("TakeoutSaaS.Domain.Products.Entities.Product", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); b.Property("CategoryId") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("所属分类。"); b.Property("CoverImage") .HasMaxLength(256) - .HasColumnType("character varying(256)"); + .HasColumnType("character varying(256)") + .HasComment("主图。"); b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); b.Property("CreatedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); b.Property("DeletedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); b.Property("DeletedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); b.Property("Description") - .HasColumnType("text"); + .HasColumnType("text") + .HasComment("商品描述。"); b.Property("EnableDelivery") - .HasColumnType("boolean"); + .HasColumnType("boolean") + .HasComment("支持配送。"); b.Property("EnableDineIn") - .HasColumnType("boolean"); + .HasColumnType("boolean") + .HasComment("支持堂食。"); b.Property("EnablePickup") - .HasColumnType("boolean"); + .HasColumnType("boolean") + .HasComment("支持自提。"); b.Property("GalleryImages") .HasMaxLength(1024) - .HasColumnType("character varying(1024)"); + .HasColumnType("character varying(1024)") + .HasComment("Gallery 图片逗号分隔。"); b.Property("IsFeatured") - .HasColumnType("boolean"); + .HasColumnType("boolean") + .HasComment("是否热门推荐。"); b.Property("MaxQuantityPerOrder") - .HasColumnType("integer"); + .HasColumnType("integer") + .HasComment("最大每单限购。"); b.Property("Name") .IsRequired() .HasMaxLength(128) - .HasColumnType("character varying(128)"); + .HasColumnType("character varying(128)") + .HasComment("商品名称。"); b.Property("OriginalPrice") .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); + .HasColumnType("numeric(18,2)") + .HasComment("原价。"); b.Property("Price") .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); + .HasColumnType("numeric(18,2)") + .HasComment("现价。"); b.Property("SpuCode") .IsRequired() .HasMaxLength(32) - .HasColumnType("character varying(32)"); + .HasColumnType("character varying(32)") + .HasComment("商品编码。"); b.Property("Status") - .HasColumnType("integer"); + .HasColumnType("integer") + .HasComment("商品状态。"); b.Property("StockQuantity") - .HasColumnType("integer"); + .HasColumnType("integer") + .HasComment("库存数量(可选)。"); b.Property("StoreId") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("所属门店。"); b.Property("Subtitle") .HasMaxLength(256) - .HasColumnType("character varying(256)"); + .HasColumnType("character varying(256)") + .HasComment("副标题/卖点。"); b.Property("TenantId") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); b.Property("Unit") .HasMaxLength(16) - .HasColumnType("character varying(16)"); + .HasColumnType("character varying(16)") + .HasComment("售卖单位(份/杯等)。"); b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); b.Property("UpdatedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); b.HasKey("Id"); @@ -526,117 +3737,655 @@ namespace TakeoutSaaS.Infrastructure.App.Migrations b.HasIndex("TenantId", "StoreId"); - b.ToTable("products", (string)null); + b.ToTable("products", null, t => + { + t.HasComment("商品(SPU)信息。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Products.Entities.ProductAddonGroup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("IsRequired") + .HasColumnType("boolean") + .HasComment("是否必选。"); + + b.Property("MaxSelect") + .HasColumnType("integer") + .HasComment("最大选择数量。"); + + b.Property("MinSelect") + .HasColumnType("integer") + .HasComment("最小选择数量。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("分组名称。"); + + b.Property("ProductId") + .HasColumnType("uuid") + .HasComment("所属商品。"); + + b.Property("SelectionType") + .HasColumnType("integer") + .HasComment("选择类型。"); + + b.Property("SortOrder") + .HasColumnType("integer") + .HasComment("排序值。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "ProductId", "Name"); + + b.ToTable("product_addon_groups", null, t => + { + t.HasComment("加料/做法分组。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Products.Entities.ProductAddonOption", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AddonGroupId") + .HasColumnType("uuid") + .HasComment("所属加料分组。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("ExtraPrice") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("附加价格。"); + + b.Property("IsDefault") + .HasColumnType("boolean") + .HasComment("是否默认选项。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("选项名称。"); + + b.Property("SortOrder") + .HasColumnType("integer") + .HasComment("排序。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.ToTable("product_addon_options", null, t => + { + t.HasComment("加料选项。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Products.Entities.ProductAttributeGroup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("IsRequired") + .HasColumnType("boolean") + .HasComment("是否必选。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("分组名称,例如“辣度”“份量”。"); + + b.Property("SelectionType") + .HasColumnType("integer") + .HasComment("选择类型(单选/多选)。"); + + b.Property("SortOrder") + .HasColumnType("integer") + .HasComment("显示排序。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("关联门店,可为空表示所有门店共享。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId", "Name"); + + b.ToTable("product_attribute_groups", null, t => + { + t.HasComment("商品规格/属性分组。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Products.Entities.ProductAttributeOption", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AttributeGroupId") + .HasColumnType("uuid") + .HasComment("所属规格组。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("ExtraPrice") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("附加价格。"); + + b.Property("IsDefault") + .HasColumnType("boolean") + .HasComment("是否默认选中。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("选项名称。"); + + b.Property("SortOrder") + .HasColumnType("integer") + .HasComment("排序。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "AttributeGroupId", "Name") + .IsUnique(); + + b.ToTable("product_attribute_options", null, t => + { + t.HasComment("商品规格选项。"); + }); }); modelBuilder.Entity("TakeoutSaaS.Domain.Products.Entities.ProductCategory", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); b.Property("CreatedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); b.Property("DeletedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); b.Property("DeletedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); b.Property("Description") .HasMaxLength(256) - .HasColumnType("character varying(256)"); + .HasColumnType("character varying(256)") + .HasComment("分类描述。"); b.Property("IsEnabled") - .HasColumnType("boolean"); + .HasColumnType("boolean") + .HasComment("是否启用。"); b.Property("Name") .IsRequired() .HasMaxLength(64) - .HasColumnType("character varying(64)"); + .HasColumnType("character varying(64)") + .HasComment("分类名称。"); b.Property("SortOrder") - .HasColumnType("integer"); + .HasColumnType("integer") + .HasComment("排序值。"); b.Property("StoreId") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("所属门店。"); b.Property("TenantId") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); b.Property("UpdatedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); b.HasKey("Id"); b.HasIndex("TenantId", "StoreId"); - b.ToTable("product_categories", (string)null); + b.ToTable("product_categories", null, t => + { + t.HasComment("商品分类。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Products.Entities.ProductMediaAsset", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("Caption") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("描述或标题。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("MediaType") + .HasColumnType("integer") + .HasComment("媒体类型。"); + + b.Property("ProductId") + .HasColumnType("uuid") + .HasComment("商品标识。"); + + b.Property("SortOrder") + .HasColumnType("integer") + .HasComment("排序。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("Url") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("character varying(512)") + .HasComment("媒资链接。"); + + b.HasKey("Id"); + + b.ToTable("product_media_assets", null, t => + { + t.HasComment("商品媒资素材。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Products.Entities.ProductPricingRule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("ConditionsJson") + .IsRequired() + .HasColumnType("text") + .HasComment("条件描述(JSON),如会员等级、渠道等。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("EndTime") + .HasColumnType("timestamp with time zone") + .HasComment("生效结束时间。"); + + b.Property("Price") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("特殊价格。"); + + b.Property("ProductId") + .HasColumnType("uuid") + .HasComment("所属商品。"); + + b.Property("RuleType") + .HasColumnType("integer") + .HasComment("策略类型。"); + + b.Property("StartTime") + .HasColumnType("timestamp with time zone") + .HasComment("生效开始时间。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("WeekdaysJson") + .HasColumnType("text") + .HasComment("生效星期(JSON 数组)。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "ProductId", "RuleType"); + + b.ToTable("product_pricing_rules", null, t => + { + t.HasComment("商品价格策略,支持会员价/时段价等。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Products.Entities.ProductSku", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AttributesJson") + .IsRequired() + .HasColumnType("text") + .HasComment("规格属性 JSON(记录选项 ID)。"); + + b.Property("Barcode") + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("条形码。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("OriginalPrice") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("原价。"); + + b.Property("Price") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("售价。"); + + b.Property("ProductId") + .HasColumnType("uuid") + .HasComment("所属商品标识。"); + + b.Property("SkuCode") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("SKU 编码。"); + + b.Property("StockQuantity") + .HasColumnType("integer") + .HasComment("可售库存。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("Weight") + .HasPrecision(10, 3) + .HasColumnType("numeric(10,3)") + .HasComment("重量(千克)。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "SkuCode") + .IsUnique(); + + b.ToTable("product_skus", null, t => + { + t.HasComment("商品 SKU,记录具体规格组合价格。"); + }); }); modelBuilder.Entity("TakeoutSaaS.Domain.Queues.Entities.QueueTicket", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); b.Property("CalledAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("叫号时间。"); b.Property("CancelledAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("取消时间。"); b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); b.Property("CreatedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); b.Property("DeletedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); b.Property("DeletedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); b.Property("EstimatedWaitMinutes") - .HasColumnType("integer"); + .HasColumnType("integer") + .HasComment("预计等待分钟。"); b.Property("ExpiredAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("过号时间。"); b.Property("PartySize") - .HasColumnType("integer"); + .HasColumnType("integer") + .HasComment("就餐人数。"); b.Property("Remark") .HasMaxLength(256) - .HasColumnType("character varying(256)"); + .HasColumnType("character varying(256)") + .HasComment("备注。"); b.Property("Status") - .HasColumnType("integer"); + .HasColumnType("integer") + .HasComment("状态。"); b.Property("StoreId") .HasColumnType("uuid"); b.Property("TenantId") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); b.Property("TicketNumber") .IsRequired() .HasMaxLength(32) - .HasColumnType("character varying(32)"); + .HasColumnType("character varying(32)") + .HasComment("排队编号。"); b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); b.Property("UpdatedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); b.HasKey("Id"); @@ -645,80 +4394,103 @@ namespace TakeoutSaaS.Infrastructure.App.Migrations b.HasIndex("TenantId", "StoreId", "TicketNumber") .IsUnique(); - b.ToTable("queue_tickets", (string)null); + b.ToTable("queue_tickets", null, t => + { + t.HasComment("排队叫号。"); + }); }); modelBuilder.Entity("TakeoutSaaS.Domain.Reservations.Entities.Reservation", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); b.Property("CancelledAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("取消时间。"); b.Property("CheckInCode") .HasMaxLength(32) - .HasColumnType("character varying(32)"); + .HasColumnType("character varying(32)") + .HasComment("核销码/到店码。"); b.Property("CheckedInAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("实际签到时间。"); b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); b.Property("CreatedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); b.Property("CustomerName") .IsRequired() .HasMaxLength(64) - .HasColumnType("character varying(64)"); + .HasColumnType("character varying(64)") + .HasComment("客户姓名。"); b.Property("CustomerPhone") .IsRequired() .HasMaxLength(32) - .HasColumnType("character varying(32)"); + .HasColumnType("character varying(32)") + .HasComment("联系电话。"); b.Property("DeletedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); b.Property("DeletedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); b.Property("PeopleCount") - .HasColumnType("integer"); + .HasColumnType("integer") + .HasComment("用餐人数。"); b.Property("Remark") .HasMaxLength(512) - .HasColumnType("character varying(512)"); + .HasColumnType("character varying(512)") + .HasComment("备注。"); b.Property("ReservationNo") .IsRequired() .HasMaxLength(32) - .HasColumnType("character varying(32)"); + .HasColumnType("character varying(32)") + .HasComment("预约号。"); b.Property("ReservationTime") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("预约时间(UTC)。"); b.Property("Status") - .HasColumnType("integer"); + .HasColumnType("integer") + .HasComment("状态。"); b.Property("StoreId") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("门店。"); b.Property("TablePreference") .HasMaxLength(64) - .HasColumnType("character varying(64)"); + .HasColumnType("character varying(64)") + .HasComment("桌型/标签。"); b.Property("TenantId") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); b.Property("UpdatedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); b.HasKey("Id"); @@ -727,198 +4499,1129 @@ namespace TakeoutSaaS.Infrastructure.App.Migrations b.HasIndex("TenantId", "StoreId"); - b.ToTable("reservations", (string)null); + b.ToTable("reservations", null, t => + { + t.HasComment("预约/预订记录。"); + }); }); modelBuilder.Entity("TakeoutSaaS.Domain.Stores.Entities.Store", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); b.Property("Address") .HasMaxLength(256) - .HasColumnType("character varying(256)"); + .HasColumnType("character varying(256)") + .HasComment("详细地址。"); b.Property("Announcement") .HasMaxLength(512) - .HasColumnType("character varying(512)"); + .HasColumnType("character varying(512)") + .HasComment("门店公告。"); b.Property("BusinessHours") .HasMaxLength(256) - .HasColumnType("character varying(256)"); + .HasColumnType("character varying(256)") + .HasComment("门店营业时段描述(备用字符串)。"); b.Property("City") .HasMaxLength(64) - .HasColumnType("character varying(64)"); + .HasColumnType("character varying(64)") + .HasComment("所在城市。"); b.Property("Code") .IsRequired() .HasMaxLength(32) - .HasColumnType("character varying(32)"); + .HasColumnType("character varying(32)") + .HasComment("门店编码,便于扫码及外部对接。"); + + b.Property("Country") + .HasColumnType("text") + .HasComment("所在国家或地区。"); + + b.Property("CoverImageUrl") + .HasColumnType("text") + .HasComment("门店海报。"); b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); b.Property("CreatedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); b.Property("DeletedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); b.Property("DeletedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); b.Property("DeliveryRadiusKm") .HasPrecision(6, 2) - .HasColumnType("numeric(6,2)"); + .HasColumnType("numeric(6,2)") + .HasComment("默认配送半径(公里)。"); + + b.Property("Description") + .HasColumnType("text") + .HasComment("门店描述或公告。"); b.Property("District") .HasMaxLength(64) - .HasColumnType("character varying(64)"); + .HasColumnType("character varying(64)") + .HasComment("区县信息。"); b.Property("Latitude") - .HasColumnType("double precision"); + .HasColumnType("double precision") + .HasComment("纬度。"); b.Property("Longitude") - .HasColumnType("double precision"); + .HasColumnType("double precision") + .HasComment("高德/腾讯地图经度。"); b.Property("ManagerName") .HasMaxLength(64) - .HasColumnType("character varying(64)"); + .HasColumnType("character varying(64)") + .HasComment("门店负责人姓名。"); b.Property("MerchantId") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("所属商户标识。"); b.Property("Name") .IsRequired() .HasMaxLength(128) - .HasColumnType("character varying(128)"); + .HasColumnType("character varying(128)") + .HasComment("门店名称。"); b.Property("Phone") .HasMaxLength(32) - .HasColumnType("character varying(32)"); + .HasColumnType("character varying(32)") + .HasComment("联系电话。"); b.Property("Province") .HasMaxLength(64) - .HasColumnType("character varying(64)"); - - b.Property("QueueEnabled") - .HasColumnType("boolean"); - - b.Property("ReservationEnabled") - .HasColumnType("boolean"); + .HasColumnType("character varying(64)") + .HasComment("所在省份。"); b.Property("Status") - .HasColumnType("integer"); + .HasColumnType("integer") + .HasComment("门店当前运营状态。"); b.Property("SupportsDelivery") - .HasColumnType("boolean"); + .HasColumnType("boolean") + .HasComment("是否支持配送。"); b.Property("SupportsDineIn") - .HasColumnType("boolean"); + .HasColumnType("boolean") + .HasComment("是否支持堂食。"); b.Property("SupportsPickup") - .HasColumnType("boolean"); + .HasColumnType("boolean") + .HasComment("是否支持自提。"); + + b.Property("SupportsQueueing") + .HasColumnType("boolean") + .HasComment("支持排队叫号。"); + + b.Property("SupportsReservation") + .HasColumnType("boolean") + .HasComment("支持预约。"); + + b.Property("Tags") + .HasColumnType("text") + .HasComment("门店标签(逗号分隔)。"); b.Property("TenantId") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); b.Property("UpdatedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); b.HasKey("Id"); - b.HasIndex("MerchantId"); - b.HasIndex("TenantId", "Code") .IsUnique(); b.HasIndex("TenantId", "MerchantId"); - b.ToTable("stores", (string)null); + b.ToTable("stores", null, t => + { + t.HasComment("门店信息,承载营业配置与能力。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Stores.Entities.StoreBusinessHour", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CapacityLimit") + .HasColumnType("integer") + .HasComment("最大接待容量或单量限制。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DayOfWeek") + .HasColumnType("integer") + .HasComment("星期几,0 表示周日。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("EndTime") + .HasColumnType("interval") + .HasComment("结束时间(本地时间)。"); + + b.Property("HourType") + .HasColumnType("integer") + .HasComment("时段类型(正常营业、休息、预约等)。"); + + b.Property("Notes") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("备注。"); + + b.Property("StartTime") + .HasColumnType("interval") + .HasComment("开始时间(本地时间)。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("门店标识。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId", "DayOfWeek"); + + b.ToTable("store_business_hours", null, t => + { + t.HasComment("门店营业时段配置。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Stores.Entities.StoreDeliveryZone", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("DeliveryFee") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("配送费。"); + + b.Property("EstimatedMinutes") + .HasColumnType("integer") + .HasComment("预计送达分钟。"); + + b.Property("MinimumOrderAmount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("起送价。"); + + b.Property("PolygonGeoJson") + .IsRequired() + .HasColumnType("text") + .HasComment("GeoJSON 表示的多边形范围。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("门店标识。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("ZoneName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("区域名称。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId", "ZoneName"); + + b.ToTable("store_delivery_zones", null, t => + { + t.HasComment("门店配送范围配置。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Stores.Entities.StoreEmployeeShift", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("EndTime") + .HasColumnType("interval") + .HasComment("结束时间。"); + + b.Property("Notes") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("备注。"); + + b.Property("RoleType") + .HasColumnType("integer") + .HasComment("排班角色。"); + + b.Property("ShiftDate") + .HasColumnType("timestamp with time zone") + .HasComment("班次日期。"); + + b.Property("StaffId") + .HasColumnType("uuid") + .HasComment("员工标识。"); + + b.Property("StartTime") + .HasColumnType("interval") + .HasComment("开始时间。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("门店标识。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId", "ShiftDate", "StaffId") + .IsUnique(); + + b.ToTable("store_employee_shifts", null, t => + { + t.HasComment("门店员工排班记录。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Stores.Entities.StoreHoliday", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("Date") + .HasColumnType("timestamp with time zone") + .HasComment("日期。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("IsClosed") + .HasColumnType("boolean") + .HasComment("是否全天闭店。"); + + b.Property("Reason") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("说明内容。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("门店标识。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId", "Date") + .IsUnique(); + + b.ToTable("store_holidays", null, t => + { + t.HasComment("门店休息日或特殊营业日。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Stores.Entities.StoreTable", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AreaId") + .HasColumnType("uuid") + .HasComment("所在区域 ID。"); + + b.Property("Capacity") + .HasColumnType("integer") + .HasComment("可容纳人数。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("QrCodeUrl") + .HasMaxLength(512) + .HasColumnType("character varying(512)") + .HasComment("桌码二维码地址。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("当前桌台状态。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("门店标识。"); + + b.Property("TableCode") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasComment("桌码。"); + + b.Property("Tags") + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("桌台标签(堂食、快餐等)。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId", "TableCode") + .IsUnique(); + + b.ToTable("store_tables", null, t => + { + t.HasComment("桌台信息与二维码绑定。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Stores.Entities.StoreTableArea", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("Description") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("区域描述。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("区域名称。"); + + b.Property("StoreId") + .HasColumnType("uuid") + .HasComment("门店标识。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StoreId", "Name") + .IsUnique(); + + b.ToTable("store_table_areas", null, t => + { + t.HasComment("门店桌台区域配置。"); + }); }); modelBuilder.Entity("TakeoutSaaS.Domain.Tenants.Entities.Tenant", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("Address") + .HasColumnType("text") + .HasComment("详细地址信息。"); + + b.Property("City") + .HasColumnType("text") + .HasComment("所在城市。"); b.Property("Code") .IsRequired() .HasMaxLength(64) - .HasColumnType("character varying(64)"); + .HasColumnType("character varying(64)") + .HasComment("租户短编码,作为跨系统引用的唯一标识。"); b.Property("ContactEmail") .HasMaxLength(128) - .HasColumnType("character varying(128)"); + .HasColumnType("character varying(128)") + .HasComment("主联系人邮箱。"); b.Property("ContactName") .HasMaxLength(64) - .HasColumnType("character varying(64)"); + .HasColumnType("character varying(64)") + .HasComment("主联系人姓名。"); b.Property("ContactPhone") .HasMaxLength(32) - .HasColumnType("character varying(32)"); + .HasColumnType("character varying(32)") + .HasComment("主联系人电话。"); + + b.Property("Country") + .HasColumnType("text") + .HasComment("所在国家/地区。"); + + b.Property("CoverImageUrl") + .HasColumnType("text") + .HasComment("品牌海报或封面图。"); b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); b.Property("CreatedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); b.Property("DeletedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); b.Property("DeletedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); b.Property("EffectiveFrom") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("服务生效时间(UTC)。"); b.Property("EffectiveTo") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("服务到期时间(UTC)。"); b.Property("Industry") .HasMaxLength(64) - .HasColumnType("character varying(64)"); + .HasColumnType("character varying(64)") + .HasComment("所属行业,如餐饮、零售等。"); + + b.Property("LegalEntityName") + .HasColumnType("text") + .HasComment("法人或公司主体名称。"); b.Property("LogoUrl") .HasMaxLength(256) - .HasColumnType("character varying(256)"); + .HasColumnType("character varying(256)") + .HasComment("LOGO 图片地址。"); b.Property("Name") .IsRequired() .HasMaxLength(128) - .HasColumnType("character varying(128)"); + .HasColumnType("character varying(128)") + .HasComment("租户全称或品牌名称。"); + + b.Property("PrimaryOwnerUserId") + .HasColumnType("uuid") + .HasComment("系统内对应的租户所有者账号 ID。"); + + b.Property("Province") + .HasColumnType("text") + .HasComment("所在省份或州。"); b.Property("Remarks") .HasMaxLength(512) - .HasColumnType("character varying(512)"); + .HasColumnType("character varying(512)") + .HasComment("备注信息,用于运营记录特殊说明。"); b.Property("ShortName") .HasMaxLength(64) - .HasColumnType("character varying(64)"); + .HasColumnType("character varying(64)") + .HasComment("对外展示的简称。"); b.Property("Status") - .HasColumnType("integer"); + .HasColumnType("integer") + .HasComment("租户当前状态,涵盖审核、启用、停用等场景。"); + + b.Property("SuspendedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次暂停服务时间。"); + + b.Property("SuspensionReason") + .HasColumnType("text") + .HasComment("暂停或终止的原因说明。"); + + b.Property("Tags") + .HasColumnType("text") + .HasComment("业务标签集合(逗号分隔)。"); b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); b.Property("UpdatedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("Website") + .HasColumnType("text") + .HasComment("官网或主要宣传链接。"); b.HasKey("Id"); b.HasIndex("Code") .IsUnique(); - b.ToTable("tenants", (string)null); + b.ToTable("tenants", null, t => + { + t.HasComment("平台租户信息,描述租户的生命周期与基础资料。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Tenants.Entities.TenantBillingStatement", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AmountDue") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("应付金额。"); + + b.Property("AmountPaid") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)") + .HasComment("实付金额。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("DueDate") + .HasColumnType("timestamp with time zone") + .HasComment("到期日。"); + + b.Property("LineItemsJson") + .HasColumnType("text") + .HasComment("账单明细 JSON,记录各项费用。"); + + b.Property("PeriodEnd") + .HasColumnType("timestamp with time zone") + .HasComment("账单周期结束时间。"); + + b.Property("PeriodStart") + .HasColumnType("timestamp with time zone") + .HasComment("账单周期开始时间。"); + + b.Property("StatementNo") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("账单编号,供对账查询。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("当前付款状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "StatementNo") + .IsUnique(); + + b.ToTable("tenant_billing_statements", null, t => + { + t.HasComment("租户账单,用于呈现周期性收费。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Tenants.Entities.TenantNotification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("Channel") + .HasColumnType("integer") + .HasComment("发布通道(站内、邮件、短信等)。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("Message") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("character varying(1024)") + .HasComment("通知正文。"); + + b.Property("MetadataJson") + .HasColumnType("text") + .HasComment("附加元数据 JSON。"); + + b.Property("ReadAt") + .HasColumnType("timestamp with time zone") + .HasComment("租户是否已阅读。"); + + b.Property("SentAt") + .HasColumnType("timestamp with time zone") + .HasComment("推送时间。"); + + b.Property("Severity") + .HasColumnType("integer") + .HasComment("通知重要级别。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("通知标题。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Channel", "SentAt"); + + b.ToTable("tenant_notifications", null, t => + { + t.HasComment("面向租户的站内通知或消息推送。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Tenants.Entities.TenantPackage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("Description") + .HasMaxLength(512) + .HasColumnType("character varying(512)") + .HasComment("套餐描述,包含适用场景、权益等。"); + + b.Property("FeaturePoliciesJson") + .HasColumnType("text") + .HasComment("权益明细 JSON,记录自定义特性开关。"); + + b.Property("IsActive") + .HasColumnType("boolean") + .HasComment("是否仍可售卖。"); + + b.Property("MaxAccountCount") + .HasColumnType("integer") + .HasComment("允许创建的最大账号数。"); + + b.Property("MaxDeliveryOrders") + .HasColumnType("integer") + .HasComment("每月可调用的配送单数量上限。"); + + b.Property("MaxSmsCredits") + .HasColumnType("integer") + .HasComment("每月短信额度上限。"); + + b.Property("MaxStorageGb") + .HasColumnType("integer") + .HasComment("存储容量上限(GB)。"); + + b.Property("MaxStoreCount") + .HasColumnType("integer") + .HasComment("允许的最大门店数。"); + + b.Property("MonthlyPrice") + .HasColumnType("numeric") + .HasComment("月付价格,单位:人民币元。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("套餐名称,展示给租户的简称。"); + + b.Property("PackageType") + .HasColumnType("integer") + .HasComment("套餐分类(试用、标准、旗舰等)。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("YearlyPrice") + .HasColumnType("numeric") + .HasComment("年付价格,单位:人民币元。"); + + b.HasKey("Id"); + + b.ToTable("tenant_packages", null, t => + { + t.HasComment("平台提供的租户套餐定义。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Tenants.Entities.TenantQuotaUsage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("LastResetAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次重置时间。"); + + b.Property("LimitValue") + .HasColumnType("numeric") + .HasComment("当前配额上限。"); + + b.Property("QuotaType") + .HasColumnType("integer") + .HasComment("配额类型,例如门店数、短信条数等。"); + + b.Property("ResetCycle") + .HasColumnType("text") + .HasComment("配额刷新周期描述(如月、年)。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("UsedValue") + .HasColumnType("numeric") + .HasComment("已消耗的数量。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "QuotaType") + .IsUnique(); + + b.ToTable("tenant_quota_usages", null, t => + { + t.HasComment("租户配额使用情况快照。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Tenants.Entities.TenantSubscription", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("AutoRenew") + .HasColumnType("boolean") + .HasComment("是否开启自动续费。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("EffectiveFrom") + .HasColumnType("timestamp with time zone") + .HasComment("订阅生效时间(UTC)。"); + + b.Property("EffectiveTo") + .HasColumnType("timestamp with time zone") + .HasComment("订阅到期时间(UTC)。"); + + b.Property("NextBillingDate") + .HasColumnType("timestamp with time zone") + .HasComment("下一个计费时间,配合自动续费使用。"); + + b.Property("Notes") + .HasColumnType("text") + .HasComment("运营备注信息。"); + + b.Property("ScheduledPackageId") + .HasColumnType("uuid") + .HasComment("若已排期升降配,对应的新套餐 ID。"); + + b.Property("Status") + .HasColumnType("integer") + .HasComment("订阅当前状态。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("TenantPackageId") + .HasColumnType("uuid") + .HasComment("当前订阅关联的套餐标识。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "TenantPackageId"); + + b.ToTable("tenant_subscriptions", null, t => + { + t.HasComment("租户套餐订阅记录。"); + }); }); modelBuilder.Entity("TakeoutSaaS.Domain.Orders.Entities.OrderItem", b => @@ -929,17 +5632,6 @@ namespace TakeoutSaaS.Infrastructure.App.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); }); - - modelBuilder.Entity("TakeoutSaaS.Domain.Stores.Entities.Store", b => - { - b.HasOne("TakeoutSaaS.Domain.Merchants.Entities.Merchant", "Merchant") - .WithMany() - .HasForeignKey("MerchantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Merchant"); - }); #pragma warning restore 612, 618 } } diff --git a/src/Infrastructure/TakeoutSaaS.Infrastructure/App/Persistence/TakeoutAppDbContext.cs b/src/Infrastructure/TakeoutSaaS.Infrastructure/App/Persistence/TakeoutAppDbContext.cs index 328a3a2..53474ea 100644 --- a/src/Infrastructure/TakeoutSaaS.Infrastructure/App/Persistence/TakeoutAppDbContext.cs +++ b/src/Infrastructure/TakeoutSaaS.Infrastructure/App/Persistence/TakeoutAppDbContext.cs @@ -1,7 +1,17 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; +using TakeoutSaaS.Domain.Analytics.Entities; +using TakeoutSaaS.Domain.Coupons.Entities; +using TakeoutSaaS.Domain.CustomerService.Entities; using TakeoutSaaS.Domain.Deliveries.Entities; +using TakeoutSaaS.Domain.Distribution.Entities; +using TakeoutSaaS.Domain.Engagement.Entities; +using TakeoutSaaS.Domain.GroupBuying.Entities; +using TakeoutSaaS.Domain.Inventory.Entities; +using TakeoutSaaS.Domain.Membership.Entities; using TakeoutSaaS.Domain.Merchants.Entities; +using TakeoutSaaS.Domain.Navigation.Entities; +using TakeoutSaaS.Domain.Ordering.Entities; using TakeoutSaaS.Domain.Orders.Entities; using TakeoutSaaS.Domain.Payments.Entities; using TakeoutSaaS.Domain.Products.Entities; @@ -25,16 +35,91 @@ public sealed class TakeoutAppDbContext( : TenantAwareDbContext(options, tenantProvider, currentUserAccessor) { public DbSet Tenants => Set(); + public DbSet TenantPackages => Set(); + public DbSet TenantSubscriptions => Set(); + public DbSet TenantQuotaUsages => Set(); + public DbSet TenantBillingStatements => Set(); + public DbSet TenantNotifications => Set(); + public DbSet Merchants => Set(); + public DbSet MerchantDocuments => Set(); + public DbSet MerchantContracts => Set(); + public DbSet MerchantStaff => Set(); + public DbSet Stores => Set(); + public DbSet StoreBusinessHours => Set(); + public DbSet StoreHolidays => Set(); + public DbSet StoreDeliveryZones => Set(); + public DbSet StoreTableAreas => Set(); + public DbSet StoreTables => Set(); + public DbSet StoreEmployeeShifts => Set(); + public DbSet ProductCategories => Set(); public DbSet Products => Set(); + public DbSet ProductAttributeGroups => Set(); + public DbSet ProductAttributeOptions => Set(); + public DbSet ProductSkus => Set(); + public DbSet ProductAddonGroups => Set(); + public DbSet ProductAddonOptions => Set(); + public DbSet ProductPricingRules => Set(); + public DbSet ProductMediaAssets => Set(); + + public DbSet InventoryItems => Set(); + public DbSet InventoryAdjustments => Set(); + public DbSet InventoryBatches => Set(); + + public DbSet ShoppingCarts => Set(); + public DbSet CartItems => Set(); + public DbSet CartItemAddons => Set(); + public DbSet CheckoutSessions => Set(); + public DbSet Orders => Set(); public DbSet OrderItems => Set(); + public DbSet OrderStatusHistories => Set(); + public DbSet RefundRequests => Set(); + public DbSet PaymentRecords => Set(); + public DbSet PaymentRefundRecords => Set(); + public DbSet Reservations => Set(); public DbSet QueueTickets => Set(); + public DbSet DeliveryOrders => Set(); + public DbSet DeliveryEvents => Set(); + + public DbSet GroupOrders => Set(); + public DbSet GroupParticipants => Set(); + + public DbSet CouponTemplates => Set(); + public DbSet Coupons => Set(); + public DbSet PromotionCampaigns => Set(); + + public DbSet MemberProfiles => Set(); + public DbSet MemberTiers => Set(); + public DbSet MemberPointLedgers => Set(); + public DbSet MemberGrowthLogs => Set(); + + public DbSet ChatSessions => Set(); + public DbSet ChatMessages => Set(); + public DbSet SupportTickets => Set(); + public DbSet TicketComments => Set(); + + public DbSet AffiliatePartners => Set(); + public DbSet AffiliateOrders => Set(); + public DbSet AffiliatePayouts => Set(); + + public DbSet CheckInCampaigns => Set(); + public DbSet CheckInRecords => Set(); + public DbSet CommunityPosts => Set(); + public DbSet CommunityComments => Set(); + public DbSet CommunityReactions => Set(); + + public DbSet MapLocations => Set(); + public DbSet NavigationRequests => Set(); + + public DbSet MetricDefinitions => Set(); + public DbSet MetricSnapshots => Set(); + public DbSet MetricAlertRules => Set(); protected override void OnModelCreating(ModelBuilder modelBuilder) { @@ -43,14 +128,72 @@ public sealed class TakeoutAppDbContext( ConfigureTenant(modelBuilder.Entity()); ConfigureMerchant(modelBuilder.Entity()); ConfigureStore(modelBuilder.Entity()); + ConfigureTenantPackage(modelBuilder.Entity()); + ConfigureTenantSubscription(modelBuilder.Entity()); + ConfigureTenantQuotaUsage(modelBuilder.Entity()); + ConfigureTenantBilling(modelBuilder.Entity()); + ConfigureTenantNotification(modelBuilder.Entity()); + ConfigureMerchantDocument(modelBuilder.Entity()); + ConfigureMerchantContract(modelBuilder.Entity()); + ConfigureMerchantStaff(modelBuilder.Entity()); + ConfigureStoreBusinessHour(modelBuilder.Entity()); + ConfigureStoreHoliday(modelBuilder.Entity()); + ConfigureStoreDeliveryZone(modelBuilder.Entity()); + ConfigureStoreTableArea(modelBuilder.Entity()); + ConfigureStoreTable(modelBuilder.Entity()); + ConfigureStoreEmployeeShift(modelBuilder.Entity()); ConfigureProductCategory(modelBuilder.Entity()); ConfigureProduct(modelBuilder.Entity()); + ConfigureProductAttributeGroup(modelBuilder.Entity()); + ConfigureProductAttributeOption(modelBuilder.Entity()); + ConfigureProductSku(modelBuilder.Entity()); + ConfigureProductAddonGroup(modelBuilder.Entity()); + ConfigureProductAddonOption(modelBuilder.Entity()); + ConfigureProductPricingRule(modelBuilder.Entity()); + ConfigureProductMediaAsset(modelBuilder.Entity()); + ConfigureInventoryItem(modelBuilder.Entity()); + ConfigureInventoryAdjustment(modelBuilder.Entity()); + ConfigureInventoryBatch(modelBuilder.Entity()); + ConfigureShoppingCart(modelBuilder.Entity()); + ConfigureCartItem(modelBuilder.Entity()); + ConfigureCartItemAddon(modelBuilder.Entity()); + ConfigureCheckoutSession(modelBuilder.Entity()); ConfigureOrder(modelBuilder.Entity()); ConfigureOrderItem(modelBuilder.Entity()); + ConfigureOrderStatusHistory(modelBuilder.Entity()); + ConfigureRefundRequest(modelBuilder.Entity()); ConfigurePaymentRecord(modelBuilder.Entity()); + ConfigurePaymentRefundRecord(modelBuilder.Entity()); ConfigureReservation(modelBuilder.Entity()); ConfigureQueueTicket(modelBuilder.Entity()); ConfigureDelivery(modelBuilder.Entity()); + ConfigureDeliveryEvent(modelBuilder.Entity()); + ConfigureGroupOrder(modelBuilder.Entity()); + ConfigureGroupParticipant(modelBuilder.Entity()); + ConfigureCouponTemplate(modelBuilder.Entity()); + ConfigureCoupon(modelBuilder.Entity()); + ConfigurePromotionCampaign(modelBuilder.Entity()); + ConfigureMemberProfile(modelBuilder.Entity()); + ConfigureMemberTier(modelBuilder.Entity()); + ConfigureMemberPointLedger(modelBuilder.Entity()); + ConfigureMemberGrowthLog(modelBuilder.Entity()); + ConfigureChatSession(modelBuilder.Entity()); + ConfigureChatMessage(modelBuilder.Entity()); + ConfigureSupportTicket(modelBuilder.Entity()); + ConfigureTicketComment(modelBuilder.Entity()); + ConfigureAffiliatePartner(modelBuilder.Entity()); + ConfigureAffiliateOrder(modelBuilder.Entity()); + ConfigureAffiliatePayout(modelBuilder.Entity()); + ConfigureCheckInCampaign(modelBuilder.Entity()); + ConfigureCheckInRecord(modelBuilder.Entity()); + ConfigureCommunityPost(modelBuilder.Entity()); + ConfigureCommunityComment(modelBuilder.Entity()); + ConfigureCommunityReaction(modelBuilder.Entity()); + ConfigureMapLocation(modelBuilder.Entity()); + ConfigureNavigationRequest(modelBuilder.Entity()); + ConfigureMetricDefinition(modelBuilder.Entity()); + ConfigureMetricSnapshot(modelBuilder.Entity()); + ConfigureMetricAlertRule(modelBuilder.Entity()); ApplyTenantQueryFilters(modelBuilder); } @@ -218,4 +361,632 @@ public sealed class TakeoutAppDbContext( builder.Property(x => x.FailureReason).HasMaxLength(256); builder.HasIndex(x => new { x.TenantId, x.OrderId }).IsUnique(); } + + private static void ConfigureTenantPackage(EntityTypeBuilder builder) + { + builder.ToTable("tenant_packages"); + builder.HasKey(x => x.Id); + builder.Property(x => x.Name).HasMaxLength(128).IsRequired(); + builder.Property(x => x.Description).HasMaxLength(512); + builder.Property(x => x.FeaturePoliciesJson).HasColumnType("text"); + } + + private static void ConfigureTenantSubscription(EntityTypeBuilder builder) + { + builder.ToTable("tenant_subscriptions"); + builder.HasKey(x => x.Id); + builder.Property(x => x.TenantPackageId).IsRequired(); + builder.Property(x => x.Status).HasConversion(); + builder.HasIndex(x => new { x.TenantId, x.TenantPackageId }); + } + + private static void ConfigureTenantQuotaUsage(EntityTypeBuilder builder) + { + builder.ToTable("tenant_quota_usages"); + builder.HasKey(x => x.Id); + builder.Property(x => x.QuotaType).HasConversion(); + builder.HasIndex(x => new { x.TenantId, x.QuotaType }).IsUnique(); + } + + private static void ConfigureTenantBilling(EntityTypeBuilder builder) + { + builder.ToTable("tenant_billing_statements"); + builder.HasKey(x => x.Id); + builder.Property(x => x.StatementNo).HasMaxLength(64).IsRequired(); + builder.Property(x => x.AmountDue).HasPrecision(18, 2); + builder.Property(x => x.AmountPaid).HasPrecision(18, 2); + builder.Property(x => x.Status).HasConversion(); + builder.Property(x => x.LineItemsJson).HasColumnType("text"); + builder.HasIndex(x => new { x.TenantId, x.StatementNo }).IsUnique(); + } + + private static void ConfigureTenantNotification(EntityTypeBuilder builder) + { + builder.ToTable("tenant_notifications"); + builder.HasKey(x => x.Id); + builder.Property(x => x.Title).HasMaxLength(128).IsRequired(); + builder.Property(x => x.Message).HasMaxLength(1024).IsRequired(); + builder.Property(x => x.Channel).HasConversion(); + builder.Property(x => x.Severity).HasConversion(); + builder.Property(x => x.MetadataJson).HasColumnType("text"); + builder.HasIndex(x => new { x.TenantId, x.Channel, x.SentAt }); + } + + private static void ConfigureMerchantDocument(EntityTypeBuilder builder) + { + builder.ToTable("merchant_documents"); + builder.HasKey(x => x.Id); + builder.Property(x => x.MerchantId).IsRequired(); + builder.Property(x => x.DocumentType).HasConversion(); + builder.Property(x => x.Status).HasConversion(); + builder.Property(x => x.FileUrl).HasMaxLength(512).IsRequired(); + builder.Property(x => x.DocumentNumber).HasMaxLength(64); + builder.HasIndex(x => new { x.TenantId, x.MerchantId, x.DocumentType }); + } + + private static void ConfigureMerchantContract(EntityTypeBuilder builder) + { + builder.ToTable("merchant_contracts"); + builder.HasKey(x => x.Id); + builder.Property(x => x.MerchantId).IsRequired(); + builder.Property(x => x.ContractNumber).HasMaxLength(64).IsRequired(); + builder.Property(x => x.FileUrl).HasMaxLength(512).IsRequired(); + builder.Property(x => x.Status).HasConversion(); + builder.Property(x => x.TerminationReason).HasMaxLength(256); + builder.HasIndex(x => new { x.TenantId, x.MerchantId, x.ContractNumber }).IsUnique(); + } + + private static void ConfigureMerchantStaff(EntityTypeBuilder builder) + { + builder.ToTable("merchant_staff"); + builder.HasKey(x => x.Id); + builder.Property(x => x.MerchantId).IsRequired(); + builder.Property(x => x.Name).HasMaxLength(64).IsRequired(); + builder.Property(x => x.Phone).HasMaxLength(32).IsRequired(); + builder.Property(x => x.Email).HasMaxLength(128); + builder.Property(x => x.RoleType).HasConversion(); + builder.Property(x => x.Status).HasConversion(); + builder.Property(x => x.PermissionsJson).HasColumnType("text"); + builder.HasIndex(x => new { x.TenantId, x.MerchantId, x.Phone }); + } + + private static void ConfigureStoreBusinessHour(EntityTypeBuilder builder) + { + builder.ToTable("store_business_hours"); + builder.HasKey(x => x.Id); + builder.Property(x => x.StoreId).IsRequired(); + builder.Property(x => x.HourType).HasConversion(); + builder.Property(x => x.Notes).HasMaxLength(256); + builder.HasIndex(x => new { x.TenantId, x.StoreId, x.DayOfWeek }); + } + + private static void ConfigureStoreHoliday(EntityTypeBuilder builder) + { + builder.ToTable("store_holidays"); + builder.HasKey(x => x.Id); + builder.Property(x => x.StoreId).IsRequired(); + builder.Property(x => x.Reason).HasMaxLength(256); + builder.HasIndex(x => new { x.TenantId, x.StoreId, x.Date }).IsUnique(); + } + + private static void ConfigureStoreDeliveryZone(EntityTypeBuilder builder) + { + builder.ToTable("store_delivery_zones"); + builder.HasKey(x => x.Id); + builder.Property(x => x.StoreId).IsRequired(); + builder.Property(x => x.ZoneName).HasMaxLength(64).IsRequired(); + builder.Property(x => x.PolygonGeoJson).HasColumnType("text").IsRequired(); + builder.Property(x => x.MinimumOrderAmount).HasPrecision(18, 2); + builder.Property(x => x.DeliveryFee).HasPrecision(18, 2); + builder.HasIndex(x => new { x.TenantId, x.StoreId, x.ZoneName }); + } + + private static void ConfigureStoreTableArea(EntityTypeBuilder builder) + { + builder.ToTable("store_table_areas"); + builder.HasKey(x => x.Id); + builder.Property(x => x.StoreId).IsRequired(); + builder.Property(x => x.Name).HasMaxLength(64).IsRequired(); + builder.Property(x => x.Description).HasMaxLength(256); + builder.HasIndex(x => new { x.TenantId, x.StoreId, x.Name }).IsUnique(); + } + + private static void ConfigureStoreTable(EntityTypeBuilder builder) + { + builder.ToTable("store_tables"); + builder.HasKey(x => x.Id); + builder.Property(x => x.StoreId).IsRequired(); + builder.Property(x => x.TableCode).HasMaxLength(32).IsRequired(); + builder.Property(x => x.Tags).HasMaxLength(128); + builder.Property(x => x.QrCodeUrl).HasMaxLength(512); + builder.HasIndex(x => new { x.TenantId, x.StoreId, x.TableCode }).IsUnique(); + } + + private static void ConfigureStoreEmployeeShift(EntityTypeBuilder builder) + { + builder.ToTable("store_employee_shifts"); + builder.HasKey(x => x.Id); + builder.Property(x => x.StoreId).IsRequired(); + builder.Property(x => x.StaffId).IsRequired(); + builder.Property(x => x.RoleType).HasConversion(); + builder.Property(x => x.Notes).HasMaxLength(256); + builder.HasIndex(x => new { x.TenantId, x.StoreId, x.ShiftDate, x.StaffId }).IsUnique(); + } + + private static void ConfigureProductAttributeGroup(EntityTypeBuilder builder) + { + builder.ToTable("product_attribute_groups"); + builder.HasKey(x => x.Id); + builder.Property(x => x.Name).HasMaxLength(64).IsRequired(); + builder.Property(x => x.SelectionType).HasConversion(); + builder.Property(x => x.StoreId); + builder.HasIndex(x => new { x.TenantId, x.StoreId, x.Name }); + } + + private static void ConfigureProductAttributeOption(EntityTypeBuilder builder) + { + builder.ToTable("product_attribute_options"); + builder.HasKey(x => x.Id); + builder.Property(x => x.AttributeGroupId).IsRequired(); + builder.Property(x => x.Name).HasMaxLength(64).IsRequired(); + builder.Property(x => x.ExtraPrice).HasPrecision(18, 2); + builder.HasIndex(x => new { x.TenantId, x.AttributeGroupId, x.Name }).IsUnique(); + } + + private static void ConfigureProductSku(EntityTypeBuilder builder) + { + builder.ToTable("product_skus"); + builder.HasKey(x => x.Id); + builder.Property(x => x.ProductId).IsRequired(); + builder.Property(x => x.SkuCode).HasMaxLength(32).IsRequired(); + builder.Property(x => x.Barcode).HasMaxLength(64); + builder.Property(x => x.Price).HasPrecision(18, 2); + builder.Property(x => x.OriginalPrice).HasPrecision(18, 2); + builder.Property(x => x.Weight).HasPrecision(10, 3); + builder.Property(x => x.AttributesJson).HasColumnType("text"); + builder.HasIndex(x => new { x.TenantId, x.SkuCode }).IsUnique(); + } + + private static void ConfigureProductAddonGroup(EntityTypeBuilder builder) + { + builder.ToTable("product_addon_groups"); + builder.HasKey(x => x.Id); + builder.Property(x => x.ProductId).IsRequired(); + builder.Property(x => x.Name).HasMaxLength(64).IsRequired(); + builder.Property(x => x.SelectionType).HasConversion(); + builder.HasIndex(x => new { x.TenantId, x.ProductId, x.Name }); + } + + private static void ConfigureProductAddonOption(EntityTypeBuilder builder) + { + builder.ToTable("product_addon_options"); + builder.HasKey(x => x.Id); + builder.Property(x => x.AddonGroupId).IsRequired(); + builder.Property(x => x.Name).HasMaxLength(64).IsRequired(); + builder.Property(x => x.ExtraPrice).HasPrecision(18, 2); + } + + private static void ConfigureProductPricingRule(EntityTypeBuilder builder) + { + builder.ToTable("product_pricing_rules"); + builder.HasKey(x => x.Id); + builder.Property(x => x.ProductId).IsRequired(); + builder.Property(x => x.RuleType).HasConversion(); + builder.Property(x => x.ConditionsJson).HasColumnType("text").IsRequired(); + builder.Property(x => x.Price).HasPrecision(18, 2); + builder.Property(x => x.WeekdaysJson).HasColumnType("text"); + builder.HasIndex(x => new { x.TenantId, x.ProductId, x.RuleType }); + } + + private static void ConfigureProductMediaAsset(EntityTypeBuilder builder) + { + builder.ToTable("product_media_assets"); + builder.HasKey(x => x.Id); + builder.Property(x => x.ProductId).IsRequired(); + builder.Property(x => x.MediaType).HasConversion(); + builder.Property(x => x.Url).HasMaxLength(512).IsRequired(); + builder.Property(x => x.Caption).HasMaxLength(256); + } + + private static void ConfigureInventoryItem(EntityTypeBuilder builder) + { + builder.ToTable("inventory_items"); + builder.HasKey(x => x.Id); + builder.Property(x => x.StoreId).IsRequired(); + builder.Property(x => x.ProductSkuId).IsRequired(); + builder.Property(x => x.BatchNumber).HasMaxLength(64); + builder.Property(x => x.Location).HasMaxLength(64); + builder.HasIndex(x => new { x.TenantId, x.StoreId, x.ProductSkuId, x.BatchNumber }); + } + + private static void ConfigureInventoryAdjustment(EntityTypeBuilder builder) + { + builder.ToTable("inventory_adjustments"); + builder.HasKey(x => x.Id); + builder.Property(x => x.InventoryItemId).IsRequired(); + builder.Property(x => x.AdjustmentType).HasConversion(); + builder.Property(x => x.Reason).HasMaxLength(256); + builder.HasIndex(x => new { x.TenantId, x.InventoryItemId, x.OccurredAt }); + } + + private static void ConfigureInventoryBatch(EntityTypeBuilder builder) + { + builder.ToTable("inventory_batches"); + builder.HasKey(x => x.Id); + builder.Property(x => x.StoreId).IsRequired(); + builder.Property(x => x.ProductSkuId).IsRequired(); + builder.Property(x => x.BatchNumber).HasMaxLength(64).IsRequired(); + builder.HasIndex(x => new { x.TenantId, x.StoreId, x.ProductSkuId, x.BatchNumber }).IsUnique(); + } + + private static void ConfigureShoppingCart(EntityTypeBuilder builder) + { + builder.ToTable("shopping_carts"); + builder.HasKey(x => x.Id); + builder.Property(x => x.UserId).IsRequired(); + builder.Property(x => x.StoreId).IsRequired(); + builder.Property(x => x.Status).HasConversion(); + builder.Property(x => x.TableContext).HasMaxLength(64); + builder.Property(x => x.DeliveryPreference).HasMaxLength(32); + builder.HasIndex(x => new { x.TenantId, x.UserId, x.StoreId }).IsUnique(); + } + + private static void ConfigureCartItem(EntityTypeBuilder builder) + { + builder.ToTable("cart_items"); + builder.HasKey(x => x.Id); + builder.Property(x => x.ShoppingCartId).IsRequired(); + builder.Property(x => x.ProductId).IsRequired(); + builder.Property(x => x.ProductName).HasMaxLength(128).IsRequired(); + builder.Property(x => x.UnitPrice).HasPrecision(18, 2); + builder.Property(x => x.Remark).HasMaxLength(256); + builder.Property(x => x.Status).HasConversion(); + builder.Property(x => x.AttributesJson).HasColumnType("text"); + builder.HasIndex(x => new { x.TenantId, x.ShoppingCartId }); + } + + private static void ConfigureCartItemAddon(EntityTypeBuilder builder) + { + builder.ToTable("cart_item_addons"); + builder.HasKey(x => x.Id); + builder.Property(x => x.CartItemId).IsRequired(); + builder.Property(x => x.Name).HasMaxLength(64).IsRequired(); + builder.Property(x => x.ExtraPrice).HasPrecision(18, 2); + } + + private static void ConfigureCheckoutSession(EntityTypeBuilder builder) + { + builder.ToTable("checkout_sessions"); + builder.HasKey(x => x.Id); + builder.Property(x => x.UserId).IsRequired(); + builder.Property(x => x.StoreId).IsRequired(); + builder.Property(x => x.SessionToken).HasMaxLength(64).IsRequired(); + builder.Property(x => x.Status).HasConversion(); + builder.Property(x => x.ValidationResultJson).HasColumnType("text").IsRequired(); + builder.HasIndex(x => new { x.TenantId, x.SessionToken }).IsUnique(); + } + + private static void ConfigureOrderStatusHistory(EntityTypeBuilder builder) + { + builder.ToTable("order_status_histories"); + builder.HasKey(x => x.Id); + builder.Property(x => x.OrderId).IsRequired(); + builder.Property(x => x.Status).HasConversion(); + builder.Property(x => x.Notes).HasMaxLength(256); + builder.HasIndex(x => new { x.TenantId, x.OrderId, x.OccurredAt }); + } + + private static void ConfigureRefundRequest(EntityTypeBuilder builder) + { + builder.ToTable("refund_requests"); + builder.HasKey(x => x.Id); + builder.Property(x => x.OrderId).IsRequired(); + builder.Property(x => x.RefundNo).HasMaxLength(32).IsRequired(); + builder.Property(x => x.Amount).HasPrecision(18, 2); + builder.Property(x => x.Reason).HasMaxLength(256).IsRequired(); + builder.Property(x => x.Status).HasConversion(); + builder.Property(x => x.ReviewNotes).HasMaxLength(256); + builder.HasIndex(x => new { x.TenantId, x.RefundNo }).IsUnique(); + } + + private static void ConfigurePaymentRefundRecord(EntityTypeBuilder builder) + { + builder.ToTable("payment_refund_records"); + builder.HasKey(x => x.Id); + builder.Property(x => x.PaymentRecordId).IsRequired(); + builder.Property(x => x.OrderId).IsRequired(); + builder.Property(x => x.Amount).HasPrecision(18, 2); + builder.Property(x => x.ChannelRefundId).HasMaxLength(64); + builder.Property(x => x.Status).HasConversion(); + builder.Property(x => x.Payload).HasColumnType("text"); + builder.HasIndex(x => new { x.TenantId, x.PaymentRecordId }); + } + + private static void ConfigureDeliveryEvent(EntityTypeBuilder builder) + { + builder.ToTable("delivery_events"); + builder.HasKey(x => x.Id); + builder.Property(x => x.DeliveryOrderId).IsRequired(); + builder.Property(x => x.EventType).HasConversion(); + builder.Property(x => x.Message).HasMaxLength(256); + builder.Property(x => x.Payload).HasColumnType("text"); + builder.HasIndex(x => new { x.TenantId, x.DeliveryOrderId, x.EventType }); + } + + private static void ConfigureGroupOrder(EntityTypeBuilder builder) + { + builder.ToTable("group_orders"); + builder.HasKey(x => x.Id); + builder.Property(x => x.GroupOrderNo).HasMaxLength(32).IsRequired(); + builder.Property(x => x.GroupPrice).HasPrecision(18, 2); + builder.Property(x => x.Status).HasConversion(); + builder.HasIndex(x => new { x.TenantId, x.GroupOrderNo }).IsUnique(); + } + + private static void ConfigureGroupParticipant(EntityTypeBuilder builder) + { + builder.ToTable("group_participants"); + builder.HasKey(x => x.Id); + builder.Property(x => x.GroupOrderId).IsRequired(); + builder.Property(x => x.OrderId).IsRequired(); + builder.Property(x => x.Status).HasConversion(); + builder.HasIndex(x => new { x.TenantId, x.GroupOrderId, x.UserId }).IsUnique(); + } + + private static void ConfigureCouponTemplate(EntityTypeBuilder builder) + { + builder.ToTable("coupon_templates"); + builder.HasKey(x => x.Id); + builder.Property(x => x.Name).HasMaxLength(128).IsRequired(); + builder.Property(x => x.CouponType).HasConversion(); + builder.Property(x => x.Description).HasMaxLength(512); + builder.Property(x => x.TotalQuantity); + builder.Property(x => x.StoreScopeJson).HasColumnType("text"); + builder.Property(x => x.ProductScopeJson).HasColumnType("text"); + builder.Property(x => x.ChannelsJson).HasColumnType("text"); + builder.Property(x => x.Status).HasConversion(); + } + + private static void ConfigureCoupon(EntityTypeBuilder builder) + { + builder.ToTable("coupons"); + builder.HasKey(x => x.Id); + builder.Property(x => x.CouponTemplateId).IsRequired(); + builder.Property(x => x.Code).HasMaxLength(32).IsRequired(); + builder.Property(x => x.Status).HasConversion(); + builder.HasIndex(x => new { x.TenantId, x.Code }).IsUnique(); + } + + private static void ConfigurePromotionCampaign(EntityTypeBuilder builder) + { + builder.ToTable("promotion_campaigns"); + builder.HasKey(x => x.Id); + builder.Property(x => x.Name).HasMaxLength(128).IsRequired(); + builder.Property(x => x.PromotionType).HasConversion(); + builder.Property(x => x.Status).HasConversion(); + builder.Property(x => x.RulesJson).HasColumnType("text").IsRequired(); + builder.Property(x => x.AudienceDescription).HasMaxLength(512); + builder.Property(x => x.BannerUrl).HasMaxLength(512); + } + + private static void ConfigureMemberProfile(EntityTypeBuilder builder) + { + builder.ToTable("member_profiles"); + builder.HasKey(x => x.Id); + builder.Property(x => x.Mobile).HasMaxLength(32).IsRequired(); + builder.Property(x => x.Nickname).HasMaxLength(64); + builder.Property(x => x.AvatarUrl).HasMaxLength(256); + builder.Property(x => x.Status).HasConversion(); + builder.HasIndex(x => new { x.TenantId, x.Mobile }).IsUnique(); + } + + private static void ConfigureMemberTier(EntityTypeBuilder builder) + { + builder.ToTable("member_tiers"); + builder.HasKey(x => x.Id); + builder.Property(x => x.Name).HasMaxLength(64).IsRequired(); + builder.Property(x => x.BenefitsJson).HasColumnType("text"); + builder.HasIndex(x => new { x.TenantId, x.Name }).IsUnique(); + } + + private static void ConfigureMemberPointLedger(EntityTypeBuilder builder) + { + builder.ToTable("member_point_ledgers"); + builder.HasKey(x => x.Id); + builder.Property(x => x.MemberId).IsRequired(); + builder.Property(x => x.Reason).HasConversion(); + builder.HasIndex(x => new { x.TenantId, x.MemberId, x.OccurredAt }); + } + + private static void ConfigureMemberGrowthLog(EntityTypeBuilder builder) + { + builder.ToTable("member_growth_logs"); + builder.HasKey(x => x.Id); + builder.Property(x => x.MemberId).IsRequired(); + builder.Property(x => x.Notes).HasMaxLength(256); + builder.HasIndex(x => new { x.TenantId, x.MemberId, x.OccurredAt }); + } + + private static void ConfigureChatSession(EntityTypeBuilder builder) + { + builder.ToTable("chat_sessions"); + builder.HasKey(x => x.Id); + builder.Property(x => x.SessionCode).HasMaxLength(64).IsRequired(); + builder.Property(x => x.Status).HasConversion(); + builder.HasIndex(x => new { x.TenantId, x.SessionCode }).IsUnique(); + } + + private static void ConfigureChatMessage(EntityTypeBuilder builder) + { + builder.ToTable("chat_messages"); + builder.HasKey(x => x.Id); + builder.Property(x => x.ChatSessionId).IsRequired(); + builder.Property(x => x.SenderType).HasConversion(); + builder.Property(x => x.ContentType).HasMaxLength(64).IsRequired(); + builder.Property(x => x.Content).HasMaxLength(1024).IsRequired(); + builder.HasIndex(x => new { x.TenantId, x.ChatSessionId, x.CreatedAt }); + } + + private static void ConfigureSupportTicket(EntityTypeBuilder builder) + { + builder.ToTable("support_tickets"); + builder.HasKey(x => x.Id); + builder.Property(x => x.TicketNo).HasMaxLength(32).IsRequired(); + builder.Property(x => x.Subject).HasMaxLength(128).IsRequired(); + builder.Property(x => x.Description).HasColumnType("text").IsRequired(); + builder.Property(x => x.Priority).HasConversion(); + builder.Property(x => x.Status).HasConversion(); + builder.HasIndex(x => new { x.TenantId, x.TicketNo }).IsUnique(); + } + + private static void ConfigureTicketComment(EntityTypeBuilder builder) + { + builder.ToTable("ticket_comments"); + builder.HasKey(x => x.Id); + builder.Property(x => x.SupportTicketId).IsRequired(); + builder.Property(x => x.Content).HasMaxLength(1024).IsRequired(); + builder.Property(x => x.AttachmentsJson).HasColumnType("text"); + builder.HasIndex(x => new { x.TenantId, x.SupportTicketId }); + } + + private static void ConfigureAffiliatePartner(EntityTypeBuilder builder) + { + builder.ToTable("affiliate_partners"); + builder.HasKey(x => x.Id); + builder.Property(x => x.DisplayName).HasMaxLength(64).IsRequired(); + builder.Property(x => x.Phone).HasMaxLength(32); + builder.Property(x => x.ChannelType).HasConversion(); + builder.Property(x => x.Status).HasConversion(); + builder.Property(x => x.Remarks).HasMaxLength(256); + builder.HasIndex(x => new { x.TenantId, x.DisplayName }); + } + + private static void ConfigureAffiliateOrder(EntityTypeBuilder builder) + { + builder.ToTable("affiliate_orders"); + builder.HasKey(x => x.Id); + builder.Property(x => x.AffiliatePartnerId).IsRequired(); + builder.Property(x => x.OrderId).IsRequired(); + builder.Property(x => x.OrderAmount).HasPrecision(18, 2); + builder.Property(x => x.EstimatedCommission).HasPrecision(18, 2); + builder.Property(x => x.Status).HasConversion(); + builder.HasIndex(x => new { x.TenantId, x.AffiliatePartnerId, x.OrderId }).IsUnique(); + } + + private static void ConfigureAffiliatePayout(EntityTypeBuilder builder) + { + builder.ToTable("affiliate_payouts"); + builder.HasKey(x => x.Id); + builder.Property(x => x.AffiliatePartnerId).IsRequired(); + builder.Property(x => x.Period).HasMaxLength(32).IsRequired(); + builder.Property(x => x.Amount).HasPrecision(18, 2); + builder.Property(x => x.Status).HasConversion(); + builder.Property(x => x.Remarks).HasMaxLength(256); + builder.HasIndex(x => new { x.TenantId, x.AffiliatePartnerId, x.Period }).IsUnique(); + } + + private static void ConfigureCheckInCampaign(EntityTypeBuilder builder) + { + builder.ToTable("checkin_campaigns"); + builder.HasKey(x => x.Id); + builder.Property(x => x.Name).HasMaxLength(128).IsRequired(); + builder.Property(x => x.Description).HasMaxLength(512); + builder.Property(x => x.RewardsJson).HasColumnType("text").IsRequired(); + builder.Property(x => x.Status).HasConversion(); + builder.HasIndex(x => new { x.TenantId, x.Name }); + } + + private static void ConfigureCheckInRecord(EntityTypeBuilder builder) + { + builder.ToTable("checkin_records"); + builder.HasKey(x => x.Id); + builder.Property(x => x.CheckInCampaignId).IsRequired(); + builder.Property(x => x.UserId).IsRequired(); + builder.Property(x => x.RewardJson).HasColumnType("text").IsRequired(); + builder.HasIndex(x => new { x.TenantId, x.CheckInCampaignId, x.UserId, x.CheckInDate }).IsUnique(); + } + + private static void ConfigureCommunityPost(EntityTypeBuilder builder) + { + builder.ToTable("community_posts"); + builder.HasKey(x => x.Id); + builder.Property(x => x.AuthorUserId).IsRequired(); + builder.Property(x => x.Title).HasMaxLength(128); + builder.Property(x => x.Content).HasColumnType("text").IsRequired(); + builder.Property(x => x.MediaJson).HasColumnType("text"); + builder.Property(x => x.Status).HasConversion(); + builder.HasIndex(x => new { x.TenantId, x.AuthorUserId, x.CreatedAt }); + } + + private static void ConfigureCommunityComment(EntityTypeBuilder builder) + { + builder.ToTable("community_comments"); + builder.HasKey(x => x.Id); + builder.Property(x => x.PostId).IsRequired(); + builder.Property(x => x.Content).HasMaxLength(512).IsRequired(); + builder.HasIndex(x => new { x.TenantId, x.PostId, x.CreatedAt }); + } + + private static void ConfigureCommunityReaction(EntityTypeBuilder builder) + { + builder.ToTable("community_reactions"); + builder.HasKey(x => x.Id); + builder.Property(x => x.PostId).IsRequired(); + builder.Property(x => x.ReactionType).HasConversion(); + builder.HasIndex(x => new { x.TenantId, x.PostId, x.UserId }).IsUnique(); + } + + private static void ConfigureMapLocation(EntityTypeBuilder builder) + { + builder.ToTable("map_locations"); + builder.HasKey(x => x.Id); + builder.Property(x => x.Name).HasMaxLength(128).IsRequired(); + builder.Property(x => x.Address).HasMaxLength(256).IsRequired(); + builder.Property(x => x.Landmark).HasMaxLength(128); + builder.HasIndex(x => new { x.TenantId, x.StoreId }); + } + + private static void ConfigureNavigationRequest(EntityTypeBuilder builder) + { + builder.ToTable("navigation_requests"); + builder.HasKey(x => x.Id); + builder.Property(x => x.UserId).IsRequired(); + builder.Property(x => x.StoreId).IsRequired(); + builder.Property(x => x.Channel).HasConversion(); + builder.Property(x => x.TargetApp).HasConversion(); + builder.HasIndex(x => new { x.TenantId, x.UserId, x.StoreId, x.RequestedAt }); + } + + private static void ConfigureMetricDefinition(EntityTypeBuilder builder) + { + builder.ToTable("metric_definitions"); + builder.HasKey(x => x.Id); + builder.Property(x => x.Code).HasMaxLength(64).IsRequired(); + builder.Property(x => x.Name).HasMaxLength(128).IsRequired(); + builder.Property(x => x.Description).HasMaxLength(512); + builder.Property(x => x.DimensionsJson).HasColumnType("text"); + builder.Property(x => x.DefaultAggregation).HasMaxLength(32).IsRequired(); + builder.HasIndex(x => new { x.TenantId, x.Code }).IsUnique(); + } + + private static void ConfigureMetricSnapshot(EntityTypeBuilder builder) + { + builder.ToTable("metric_snapshots"); + builder.HasKey(x => x.Id); + builder.Property(x => x.MetricDefinitionId).IsRequired(); + builder.Property(x => x.DimensionKey).HasMaxLength(256).IsRequired(); + builder.Property(x => x.Value).HasPrecision(18, 4); + builder.HasIndex(x => new { x.TenantId, x.MetricDefinitionId, x.DimensionKey, x.WindowStart, x.WindowEnd }).IsUnique(); + } + + private static void ConfigureMetricAlertRule(EntityTypeBuilder builder) + { + builder.ToTable("metric_alert_rules"); + builder.HasKey(x => x.Id); + builder.Property(x => x.MetricDefinitionId).IsRequired(); + builder.Property(x => x.ConditionJson).HasColumnType("text").IsRequired(); + builder.Property(x => x.Severity).HasConversion(); + builder.Property(x => x.NotificationChannels).HasMaxLength(256); + builder.HasIndex(x => new { x.TenantId, x.MetricDefinitionId, x.Severity }); + } } diff --git a/src/Infrastructure/TakeoutSaaS.Infrastructure/App/Persistence/TakeoutAppDesignTimeDbContextFactory.cs b/src/Infrastructure/TakeoutSaaS.Infrastructure/App/Persistence/TakeoutAppDesignTimeDbContextFactory.cs index b56f2d0..e29572b 100644 --- a/src/Infrastructure/TakeoutSaaS.Infrastructure/App/Persistence/TakeoutAppDesignTimeDbContextFactory.cs +++ b/src/Infrastructure/TakeoutSaaS.Infrastructure/App/Persistence/TakeoutAppDesignTimeDbContextFactory.cs @@ -1,5 +1,6 @@ using Microsoft.EntityFrameworkCore; using TakeoutSaaS.Infrastructure.Common.Persistence.DesignTime; +using TakeoutSaaS.Shared.Abstractions.Constants; using TakeoutSaaS.Shared.Abstractions.Security; using TakeoutSaaS.Shared.Abstractions.Tenancy; @@ -12,7 +13,7 @@ internal sealed class TakeoutAppDesignTimeDbContextFactory : DesignTimeDbContextFactoryBase { public TakeoutAppDesignTimeDbContextFactory() - : base("TAKEOUTSAAS_APP_CONNECTION", "takeout_saas_app") + : base(DatabaseConstants.AppDataSource, "TAKEOUTSAAS_APP_CONNECTION") { } diff --git a/src/Infrastructure/TakeoutSaaS.Infrastructure/Common/Persistence/AppDbContext.cs b/src/Infrastructure/TakeoutSaaS.Infrastructure/Common/Persistence/AppDbContext.cs index 0a59c66..068a88f 100644 --- a/src/Infrastructure/TakeoutSaaS.Infrastructure/Common/Persistence/AppDbContext.cs +++ b/src/Infrastructure/TakeoutSaaS.Infrastructure/Common/Persistence/AppDbContext.cs @@ -21,6 +21,7 @@ public abstract class AppDbContext(DbContextOptions options, ICurrentUserAccesso { base.OnModelCreating(modelBuilder); ApplySoftDeleteQueryFilters(modelBuilder); + modelBuilder.ApplyXmlComments(); } /// diff --git a/src/Infrastructure/TakeoutSaaS.Infrastructure/Common/Persistence/DesignTime/DesignTimeDbContextFactoryBase.cs b/src/Infrastructure/TakeoutSaaS.Infrastructure/Common/Persistence/DesignTime/DesignTimeDbContextFactoryBase.cs index 88ba403..c3f59f2 100644 --- a/src/Infrastructure/TakeoutSaaS.Infrastructure/Common/Persistence/DesignTime/DesignTimeDbContextFactoryBase.cs +++ b/src/Infrastructure/TakeoutSaaS.Infrastructure/Common/Persistence/DesignTime/DesignTimeDbContextFactoryBase.cs @@ -1,25 +1,33 @@ using System; +using System.IO; +using System.Linq; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; -using TakeoutSaaS.Infrastructure.Common.Persistence; +using Microsoft.Extensions.Configuration; +using TakeoutSaaS.Infrastructure.Common.Options; using TakeoutSaaS.Shared.Abstractions.Security; using TakeoutSaaS.Shared.Abstractions.Tenancy; namespace TakeoutSaaS.Infrastructure.Common.Persistence.DesignTime; /// -/// EF Core 设计时 DbContext 工厂基类,提供统一的连接串与依赖替身。 +/// EF Core 设计时 DbContext 工厂基类,统一读取 appsettings 中的数据库配置。 /// internal abstract class DesignTimeDbContextFactoryBase : IDesignTimeDbContextFactory where TContext : TenantAwareDbContext { - private readonly string _connectionStringEnvVar; - private readonly string _defaultDatabase; + private readonly string _dataSourceName; + private readonly string? _connectionStringEnvVar; - protected DesignTimeDbContextFactoryBase(string connectionStringEnvVar, string defaultDatabase) + protected DesignTimeDbContextFactoryBase(string dataSourceName, string? connectionStringEnvVar = null) { + if (string.IsNullOrWhiteSpace(dataSourceName)) + { + throw new ArgumentException("数据源名称不能为空。", nameof(dataSourceName)); + } + + _dataSourceName = dataSourceName; _connectionStringEnvVar = connectionStringEnvVar; - _defaultDatabase = defaultDatabase; } public TContext CreateDbContext(string[] args) @@ -46,15 +54,91 @@ internal abstract class DesignTimeDbContextFactoryBase : IDesignTimeDb private string ResolveConnectionString() { - var env = Environment.GetEnvironmentVariable(_connectionStringEnvVar); - if (!string.IsNullOrWhiteSpace(env)) + if (!string.IsNullOrWhiteSpace(_connectionStringEnvVar)) { - return env; + var envValue = Environment.GetEnvironmentVariable(_connectionStringEnvVar); + if (!string.IsNullOrWhiteSpace(envValue)) + { + return envValue; + } } - return $"Host=localhost;Port=5432;Database={_defaultDatabase};Username=postgres;Password=postgres"; + var configuration = BuildConfiguration(); + var writeConnection = configuration[$"{DatabaseOptions.SectionName}:DataSources:{_dataSourceName}:Write"]; + if (string.IsNullOrWhiteSpace(writeConnection)) + { + throw new InvalidOperationException( + $"未在配置中找到数据源 '{_dataSourceName}' 的 Write 连接字符串,请检查 appsettings 或设置 {_connectionStringEnvVar ?? "相应"} 环境变量。"); + } + + return writeConnection; } + private static IConfigurationRoot BuildConfiguration() + { + var basePath = ResolveConfigurationDirectory(); + var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Development"; + + return new ConfigurationBuilder() + .SetBasePath(basePath) + .AddJsonFile("appsettings.json", optional: true, reloadOnChange: false) + .AddJsonFile($"appsettings.{environment}.json", optional: true, reloadOnChange: false) + .AddEnvironmentVariables() + .Build(); + } + + private static string ResolveConfigurationDirectory() + { + var explicitDir = Environment.GetEnvironmentVariable("TAKEOUTSAAS_APPSETTINGS_DIR"); + if (!string.IsNullOrWhiteSpace(explicitDir) && Directory.Exists(explicitDir)) + { + return explicitDir; + } + + var currentDir = Directory.GetCurrentDirectory(); + var solutionRoot = LocateSolutionRoot(currentDir); + + var candidateDirs = new[] + { + currentDir, + solutionRoot, + solutionRoot is null ? null : Path.Combine(solutionRoot, "src", "Api", "TakeoutSaaS.AdminApi"), + solutionRoot is null ? null : Path.Combine(solutionRoot, "src", "Api", "TakeoutSaaS.UserApi"), + solutionRoot is null ? null : Path.Combine(solutionRoot, "src", "Api", "TakeoutSaaS.MiniApi") + }.Where(dir => !string.IsNullOrWhiteSpace(dir)); + + foreach (var dir in candidateDirs) + { + if (dir != null && Directory.Exists(dir) && HasAppSettings(dir)) + { + return dir; + } + } + + throw new InvalidOperationException( + "未找到 appsettings 配置文件,请设置 TAKEOUTSAAS_APPSETTINGS_DIR 环境变量指向包含 appsettings*.json 的目录。"); + } + + private static string? LocateSolutionRoot(string currentPath) + { + var directoryInfo = new DirectoryInfo(currentPath); + while (directoryInfo != null) + { + if (File.Exists(Path.Combine(directoryInfo.FullName, "TakeoutSaaS.sln"))) + { + return directoryInfo.FullName; + } + + directoryInfo = directoryInfo.Parent; + } + + return null; + } + + private static bool HasAppSettings(string directory) => + File.Exists(Path.Combine(directory, "appsettings.json")) || + Directory.GetFiles(directory, "appsettings.*.json").Length > 0; + private sealed class DesignTimeTenantProvider : ITenantProvider { public Guid GetCurrentTenantId() => Guid.Empty; diff --git a/src/Infrastructure/TakeoutSaaS.Infrastructure/Common/Persistence/ModelBuilderCommentExtensions.cs b/src/Infrastructure/TakeoutSaaS.Infrastructure/Common/Persistence/ModelBuilderCommentExtensions.cs new file mode 100644 index 0000000..e143c8f --- /dev/null +++ b/src/Infrastructure/TakeoutSaaS.Infrastructure/Common/Persistence/ModelBuilderCommentExtensions.cs @@ -0,0 +1,136 @@ +using System.Collections.Concurrent; +using System.Reflection; +using System.Xml.Linq; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata; + +namespace TakeoutSaaS.Infrastructure.Common.Persistence; + +/// +/// Applies XML documentation summaries to EF Core entities/columns as comments. +/// +internal static class ModelBuilderCommentExtensions +{ + public static void ApplyXmlComments(this ModelBuilder modelBuilder) + { + foreach (var entityType in modelBuilder.Model.GetEntityTypes()) + { + ApplyEntityComment(entityType); + } + } + + private static void ApplyEntityComment(IMutableEntityType entityType) + { + var clrType = entityType.ClrType; + if (clrType == null) + { + return; + } + + if (XmlDocCommentProvider.TryGetSummary(clrType, out var typeComment)) + { + entityType.SetComment(typeComment); + } + + foreach (var property in entityType.GetProperties()) + { + var propertyInfo = property.PropertyInfo; + if (propertyInfo == null) + { + continue; + } + + if (XmlDocCommentProvider.TryGetSummary(propertyInfo, out var propertyComment)) + { + property.SetComment(propertyComment); + } + } + } + + private static class XmlDocCommentProvider + { + private static readonly ConcurrentDictionary> Cache = new(); + + public static bool TryGetSummary(MemberInfo member, out string? summary) + { + summary = null; + var assembly = member switch + { + Type type => type.Assembly, + _ => member.DeclaringType?.Assembly + }; + + if (assembly == null) + { + return false; + } + + var map = Cache.GetOrAdd(assembly, LoadComments); + if (map.Count == 0) + { + return false; + } + + var key = GetMemberKey(member); + if (key == null || !map.TryGetValue(key, out var text)) + { + return false; + } + + summary = text; + return true; + } + + private static IReadOnlyDictionary LoadComments(Assembly assembly) + { + var dictionary = new Dictionary(StringComparer.Ordinal); + var xmlPath = Path.ChangeExtension(assembly.Location, ".xml"); + if (string.IsNullOrWhiteSpace(xmlPath) || !File.Exists(xmlPath)) + { + return dictionary; + } + + var document = XDocument.Load(xmlPath); + foreach (var member in document.Descendants("member")) + { + var name = member.Attribute("name")?.Value; + if (string.IsNullOrWhiteSpace(name)) + { + continue; + } + + var summary = member.Element("summary")?.Value; + if (string.IsNullOrWhiteSpace(summary)) + { + continue; + } + + var normalized = Normalize(summary); + if (!string.IsNullOrWhiteSpace(normalized)) + { + dictionary[name] = normalized; + } + } + + return dictionary; + } + + private static string? GetMemberKey(MemberInfo member) => + member switch + { + Type type => $"T:{GetFullName(type)}", + PropertyInfo property => $"P:{GetFullName(property.DeclaringType!)}.{property.Name}", + FieldInfo field => $"F:{GetFullName(field.DeclaringType!)}.{field.Name}", + _ => null + }; + + private static string GetFullName(Type type) => + (type.FullName ?? type.Name).Replace('+', '.'); + + private static string Normalize(string text) + { + var chars = text.Replace('\r', ' ').Replace('\n', ' ').Replace('\t', ' '); + return string.Join(' ', chars.Split(' ', StringSplitOptions.RemoveEmptyEntries)); + } + } +} diff --git a/src/Infrastructure/TakeoutSaaS.Infrastructure/Dictionary/Extensions/DictionaryServiceCollectionExtensions.cs b/src/Infrastructure/TakeoutSaaS.Infrastructure/Dictionary/Extensions/DictionaryServiceCollectionExtensions.cs index be31f5a..c680f1e 100644 --- a/src/Infrastructure/TakeoutSaaS.Infrastructure/Dictionary/Extensions/DictionaryServiceCollectionExtensions.cs +++ b/src/Infrastructure/TakeoutSaaS.Infrastructure/Dictionary/Extensions/DictionaryServiceCollectionExtensions.cs @@ -28,7 +28,7 @@ public static class DictionaryServiceCollectionExtensions public static IServiceCollection AddDictionaryInfrastructure(this IServiceCollection services, IConfiguration configuration) { services.AddDatabaseInfrastructure(configuration); - services.AddPostgresDbContext(DatabaseConstants.AppDataSource); + services.AddPostgresDbContext(DatabaseConstants.DictionaryDataSource); services.AddScoped(); services.AddScoped(); diff --git a/src/Infrastructure/TakeoutSaaS.Infrastructure/Dictionary/Migrations/20251201094456_AddEntityComments.Designer.cs b/src/Infrastructure/TakeoutSaaS.Infrastructure/Dictionary/Migrations/20251201094456_AddEntityComments.Designer.cs new file mode 100644 index 0000000..2f36f70 --- /dev/null +++ b/src/Infrastructure/TakeoutSaaS.Infrastructure/Dictionary/Migrations/20251201094456_AddEntityComments.Designer.cs @@ -0,0 +1,206 @@ +// +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.Dictionary.Migrations +{ + [DbContext(typeof(DictionaryDbContext))] + [Migration("20251201094456_AddEntityComments")] + partial class AddEntityComments + { + /// + 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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("分组编码(唯一)。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("Description") + .HasMaxLength(512) + .HasColumnType("character varying(512)") + .HasComment("描述信息。"); + + b.Property("IsEnabled") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true) + .HasComment("是否启用。"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("分组名称。"); + + b.Property("Scope") + .HasColumnType("integer") + .HasComment("分组作用域:系统/业务。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("Description") + .HasMaxLength(512) + .HasColumnType("character varying(512)") + .HasComment("描述信息。"); + + b.Property("GroupId") + .HasColumnType("uuid") + .HasComment("关联分组 ID。"); + + b.Property("IsDefault") + .HasColumnType("boolean") + .HasComment("是否默认项。"); + + b.Property("IsEnabled") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true) + .HasComment("是否启用。"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("字典项键。"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(100) + .HasComment("排序值,越小越靠前。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.Property("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 + } + } +} diff --git a/src/Infrastructure/TakeoutSaaS.Infrastructure/Dictionary/Migrations/20251201094456_AddEntityComments.cs b/src/Infrastructure/TakeoutSaaS.Infrastructure/Dictionary/Migrations/20251201094456_AddEntityComments.cs new file mode 100644 index 0000000..2447766 --- /dev/null +++ b/src/Infrastructure/TakeoutSaaS.Infrastructure/Dictionary/Migrations/20251201094456_AddEntityComments.cs @@ -0,0 +1,599 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace TakeoutSaaS.Infrastructure.Dictionary.Migrations +{ + /// + public partial class AddEntityComments : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterTable( + name: "dictionary_items", + comment: "参数字典项。"); + + migrationBuilder.AlterTable( + name: "dictionary_groups", + comment: "参数字典分组(系统参数、业务参数)。"); + + migrationBuilder.AlterColumn( + name: "Value", + table: "dictionary_items", + type: "character varying(256)", + maxLength: 256, + nullable: false, + comment: "字典项值。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "dictionary_items", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "dictionary_items", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "dictionary_items", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "SortOrder", + table: "dictionary_items", + type: "integer", + nullable: false, + defaultValue: 100, + comment: "排序值,越小越靠前。", + oldClrType: typeof(int), + oldType: "integer", + oldDefaultValue: 100); + + migrationBuilder.AlterColumn( + name: "Key", + table: "dictionary_items", + type: "character varying(64)", + maxLength: 64, + nullable: false, + comment: "字典项键。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64); + + migrationBuilder.AlterColumn( + name: "IsEnabled", + table: "dictionary_items", + type: "boolean", + nullable: false, + defaultValue: true, + comment: "是否启用。", + oldClrType: typeof(bool), + oldType: "boolean", + oldDefaultValue: true); + + migrationBuilder.AlterColumn( + name: "IsDefault", + table: "dictionary_items", + type: "boolean", + nullable: false, + comment: "是否默认项。", + oldClrType: typeof(bool), + oldType: "boolean"); + + migrationBuilder.AlterColumn( + name: "GroupId", + table: "dictionary_items", + type: "uuid", + nullable: false, + comment: "关联分组 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Description", + table: "dictionary_items", + type: "character varying(512)", + maxLength: 512, + nullable: true, + comment: "描述信息。", + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "dictionary_items", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "dictionary_items", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "dictionary_items", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "dictionary_items", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "dictionary_items", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "dictionary_groups", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "dictionary_groups", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "dictionary_groups", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Scope", + table: "dictionary_groups", + type: "integer", + nullable: false, + comment: "分组作用域:系统/业务。", + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "dictionary_groups", + type: "character varying(128)", + maxLength: 128, + nullable: false, + comment: "分组名称。", + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128); + + migrationBuilder.AlterColumn( + name: "IsEnabled", + table: "dictionary_groups", + type: "boolean", + nullable: false, + defaultValue: true, + comment: "是否启用。", + oldClrType: typeof(bool), + oldType: "boolean", + oldDefaultValue: true); + + migrationBuilder.AlterColumn( + name: "Description", + table: "dictionary_groups", + type: "character varying(512)", + maxLength: 512, + nullable: true, + comment: "描述信息。", + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "dictionary_groups", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "dictionary_groups", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "dictionary_groups", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "dictionary_groups", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Code", + table: "dictionary_groups", + type: "character varying(64)", + maxLength: 64, + nullable: false, + comment: "分组编码(唯一)。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64); + + migrationBuilder.AlterColumn( + name: "Id", + table: "dictionary_groups", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterTable( + name: "dictionary_items", + oldComment: "参数字典项。"); + + migrationBuilder.AlterTable( + name: "dictionary_groups", + oldComment: "参数字典分组(系统参数、业务参数)。"); + + migrationBuilder.AlterColumn( + name: "Value", + table: "dictionary_items", + type: "character varying(256)", + maxLength: 256, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldComment: "字典项值。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "dictionary_items", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "dictionary_items", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "dictionary_items", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "SortOrder", + table: "dictionary_items", + type: "integer", + nullable: false, + defaultValue: 100, + oldClrType: typeof(int), + oldType: "integer", + oldDefaultValue: 100, + oldComment: "排序值,越小越靠前。"); + + migrationBuilder.AlterColumn( + name: "Key", + table: "dictionary_items", + type: "character varying(64)", + maxLength: 64, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldComment: "字典项键。"); + + migrationBuilder.AlterColumn( + name: "IsEnabled", + table: "dictionary_items", + type: "boolean", + nullable: false, + defaultValue: true, + oldClrType: typeof(bool), + oldType: "boolean", + oldDefaultValue: true, + oldComment: "是否启用。"); + + migrationBuilder.AlterColumn( + name: "IsDefault", + table: "dictionary_items", + type: "boolean", + nullable: false, + oldClrType: typeof(bool), + oldType: "boolean", + oldComment: "是否默认项。"); + + migrationBuilder.AlterColumn( + name: "GroupId", + table: "dictionary_items", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "关联分组 ID。"); + + migrationBuilder.AlterColumn( + name: "Description", + table: "dictionary_items", + type: "character varying(512)", + maxLength: 512, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldNullable: true, + oldComment: "描述信息。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "dictionary_items", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "dictionary_items", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "dictionary_items", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "dictionary_items", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "dictionary_items", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "dictionary_groups", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "dictionary_groups", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "dictionary_groups", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "Scope", + table: "dictionary_groups", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer", + oldComment: "分组作用域:系统/业务。"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "dictionary_groups", + type: "character varying(128)", + maxLength: 128, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldComment: "分组名称。"); + + migrationBuilder.AlterColumn( + name: "IsEnabled", + table: "dictionary_groups", + type: "boolean", + nullable: false, + defaultValue: true, + oldClrType: typeof(bool), + oldType: "boolean", + oldDefaultValue: true, + oldComment: "是否启用。"); + + migrationBuilder.AlterColumn( + name: "Description", + table: "dictionary_groups", + type: "character varying(512)", + maxLength: 512, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldNullable: true, + oldComment: "描述信息。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "dictionary_groups", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "dictionary_groups", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "dictionary_groups", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "dictionary_groups", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Code", + table: "dictionary_groups", + type: "character varying(64)", + maxLength: 64, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldComment: "分组编码(唯一)。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "dictionary_groups", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + } + } +} diff --git a/src/Infrastructure/TakeoutSaaS.Infrastructure/Dictionary/Migrations/DictionaryDbContextModelSnapshot.cs b/src/Infrastructure/TakeoutSaaS.Infrastructure/Dictionary/Migrations/DictionaryDbContextModelSnapshot.cs index 0c08edf..d55b340 100644 --- a/src/Infrastructure/TakeoutSaaS.Infrastructure/Dictionary/Migrations/DictionaryDbContextModelSnapshot.cs +++ b/src/Infrastructure/TakeoutSaaS.Infrastructure/Dictionary/Migrations/DictionaryDbContextModelSnapshot.cs @@ -26,50 +26,63 @@ namespace TakeoutSaaS.Infrastructure.Dictionary.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); b.Property("Code") .IsRequired() .HasMaxLength(64) - .HasColumnType("character varying(64)"); + .HasColumnType("character varying(64)") + .HasComment("分组编码(唯一)。"); b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); b.Property("CreatedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); b.Property("DeletedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); b.Property("DeletedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); b.Property("Description") .HasMaxLength(512) - .HasColumnType("character varying(512)"); + .HasColumnType("character varying(512)") + .HasComment("描述信息。"); b.Property("IsEnabled") .ValueGeneratedOnAdd() .HasColumnType("boolean") - .HasDefaultValue(true); + .HasDefaultValue(true) + .HasComment("是否启用。"); b.Property("Name") .IsRequired() .HasMaxLength(128) - .HasColumnType("character varying(128)"); + .HasColumnType("character varying(128)") + .HasComment("分组名称。"); b.Property("Scope") - .HasColumnType("integer"); + .HasColumnType("integer") + .HasComment("分组作用域:系统/业务。"); b.Property("TenantId") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); b.Property("UpdatedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); b.HasKey("Id"); @@ -78,65 +91,83 @@ namespace TakeoutSaaS.Infrastructure.Dictionary.Migrations b.HasIndex("TenantId", "Code") .IsUnique(); - b.ToTable("dictionary_groups", (string)null); + b.ToTable("dictionary_groups", null, t => + { + t.HasComment("参数字典分组(系统参数、业务参数)。"); + }); }); modelBuilder.Entity("TakeoutSaaS.Domain.Dictionary.Entities.DictionaryItem", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); b.Property("CreatedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); b.Property("DeletedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); b.Property("DeletedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); b.Property("Description") .HasMaxLength(512) - .HasColumnType("character varying(512)"); + .HasColumnType("character varying(512)") + .HasComment("描述信息。"); b.Property("GroupId") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("关联分组 ID。"); b.Property("IsDefault") - .HasColumnType("boolean"); + .HasColumnType("boolean") + .HasComment("是否默认项。"); b.Property("IsEnabled") .ValueGeneratedOnAdd() .HasColumnType("boolean") - .HasDefaultValue(true); + .HasDefaultValue(true) + .HasComment("是否启用。"); b.Property("Key") .IsRequired() .HasMaxLength(64) - .HasColumnType("character varying(64)"); + .HasColumnType("character varying(64)") + .HasComment("字典项键。"); b.Property("SortOrder") .ValueGeneratedOnAdd() .HasColumnType("integer") - .HasDefaultValue(100); + .HasDefaultValue(100) + .HasComment("排序值,越小越靠前。"); b.Property("TenantId") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); b.Property("UpdatedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); b.Property("Value") .IsRequired() .HasMaxLength(256) - .HasColumnType("character varying(256)"); + .HasColumnType("character varying(256)") + .HasComment("字典项值。"); b.HasKey("Id"); @@ -145,7 +176,10 @@ namespace TakeoutSaaS.Infrastructure.Dictionary.Migrations b.HasIndex("GroupId", "Key") .IsUnique(); - b.ToTable("dictionary_items", (string)null); + b.ToTable("dictionary_items", null, t => + { + t.HasComment("参数字典项。"); + }); }); modelBuilder.Entity("TakeoutSaaS.Domain.Dictionary.Entities.DictionaryItem", b => diff --git a/src/Infrastructure/TakeoutSaaS.Infrastructure/Dictionary/Persistence/DictionaryDesignTimeDbContextFactory.cs b/src/Infrastructure/TakeoutSaaS.Infrastructure/Dictionary/Persistence/DictionaryDesignTimeDbContextFactory.cs index c69074c..45d82e2 100644 --- a/src/Infrastructure/TakeoutSaaS.Infrastructure/Dictionary/Persistence/DictionaryDesignTimeDbContextFactory.cs +++ b/src/Infrastructure/TakeoutSaaS.Infrastructure/Dictionary/Persistence/DictionaryDesignTimeDbContextFactory.cs @@ -1,5 +1,6 @@ using Microsoft.EntityFrameworkCore; using TakeoutSaaS.Infrastructure.Common.Persistence.DesignTime; +using TakeoutSaaS.Shared.Abstractions.Constants; using TakeoutSaaS.Shared.Abstractions.Security; using TakeoutSaaS.Shared.Abstractions.Tenancy; @@ -12,7 +13,7 @@ internal sealed class DictionaryDesignTimeDbContextFactory : DesignTimeDbContextFactoryBase { public DictionaryDesignTimeDbContextFactory() - : base("TAKEOUTSAAS_APP_CONNECTION", "takeout_saas_app") + : base(DatabaseConstants.DictionaryDataSource, "TAKEOUTSAAS_DICTIONARY_CONNECTION") { } diff --git a/src/Infrastructure/TakeoutSaaS.Infrastructure/Identity/Migrations/20251201094410_AddEntityComments.Designer.cs b/src/Infrastructure/TakeoutSaaS.Infrastructure/Identity/Migrations/20251201094410_AddEntityComments.Designer.cs new file mode 100644 index 0000000..9f9c680 --- /dev/null +++ b/src/Infrastructure/TakeoutSaaS.Infrastructure/Identity/Migrations/20251201094410_AddEntityComments.Designer.cs @@ -0,0 +1,185 @@ +// +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.Identity.Persistence; + +#nullable disable + +namespace TakeoutSaaS.Infrastructure.Identity.Migrations +{ + [DbContext(typeof(IdentityDbContext))] + [Migration("20251201094410_AddEntityComments")] + partial class AddEntityComments + { + /// + 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.Identity.Entities.IdentityUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("Account") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("登录账号。"); + + b.Property("Avatar") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("头像地址。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("展示名称。"); + + b.Property("MerchantId") + .HasColumnType("uuid") + .HasComment("所属商户(平台管理员为空)。"); + + b.Property("PasswordHash") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("密码哈希。"); + + b.Property("Permissions") + .IsRequired() + .HasColumnType("text") + .HasComment("权限集合。"); + + b.Property("Roles") + .IsRequired() + .HasColumnType("text") + .HasComment("角色集合。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "Account") + .IsUnique(); + + b.ToTable("identity_users", null, t => + { + t.HasComment("管理后台账户实体(平台管理员、租户管理员或商户员工)。"); + }); + }); + + modelBuilder.Entity("TakeoutSaaS.Domain.Identity.Entities.MiniUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); + + b.Property("Avatar") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasComment("头像地址。"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); + + b.Property("CreatedBy") + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); + + b.Property("DeletedBy") + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); + + b.Property("Nickname") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)") + .HasComment("昵称。"); + + b.Property("OpenId") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("微信 OpenId。"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); + + b.Property("UnionId") + .HasMaxLength(128) + .HasColumnType("character varying(128)") + .HasComment("微信 UnionId,可能为空。"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); + + b.Property("UpdatedBy") + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); + + b.HasKey("Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "OpenId") + .IsUnique(); + + b.ToTable("mini_users", null, t => + { + t.HasComment("小程序用户实体。"); + }); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Infrastructure/TakeoutSaaS.Infrastructure/Identity/Migrations/20251201094410_AddEntityComments.cs b/src/Infrastructure/TakeoutSaaS.Infrastructure/Identity/Migrations/20251201094410_AddEntityComments.cs new file mode 100644 index 0000000..5f0481b --- /dev/null +++ b/src/Infrastructure/TakeoutSaaS.Infrastructure/Identity/Migrations/20251201094410_AddEntityComments.cs @@ -0,0 +1,581 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace TakeoutSaaS.Infrastructure.Identity.Migrations +{ + /// + public partial class AddEntityComments : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterTable( + name: "mini_users", + comment: "小程序用户实体。"); + + migrationBuilder.AlterTable( + name: "identity_users", + comment: "管理后台账户实体(平台管理员、租户管理员或商户员工)。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "mini_users", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "mini_users", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UnionId", + table: "mini_users", + type: "character varying(128)", + maxLength: 128, + nullable: true, + comment: "微信 UnionId,可能为空。", + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "mini_users", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "OpenId", + table: "mini_users", + type: "character varying(128)", + maxLength: 128, + nullable: false, + comment: "微信 OpenId。", + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128); + + migrationBuilder.AlterColumn( + name: "Nickname", + table: "mini_users", + type: "character varying(64)", + maxLength: 64, + nullable: false, + comment: "昵称。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "mini_users", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "mini_users", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "mini_users", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "mini_users", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Avatar", + table: "mini_users", + type: "character varying(256)", + maxLength: 256, + nullable: true, + comment: "头像地址。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Id", + table: "mini_users", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "identity_users", + type: "uuid", + nullable: true, + comment: "最后更新人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "identity_users", + type: "timestamp with time zone", + nullable: true, + comment: "最近一次更新时间(UTC),从未更新时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "identity_users", + type: "uuid", + nullable: false, + comment: "所属租户 ID。", + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Roles", + table: "identity_users", + type: "text", + nullable: false, + comment: "角色集合。", + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "Permissions", + table: "identity_users", + type: "text", + nullable: false, + comment: "权限集合。", + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "PasswordHash", + table: "identity_users", + type: "character varying(256)", + maxLength: 256, + nullable: false, + comment: "密码哈希。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256); + + migrationBuilder.AlterColumn( + name: "MerchantId", + table: "identity_users", + type: "uuid", + nullable: true, + comment: "所属商户(平台管理员为空)。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DisplayName", + table: "identity_users", + type: "character varying(64)", + maxLength: 64, + nullable: false, + comment: "展示名称。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "identity_users", + type: "uuid", + nullable: true, + comment: "删除人用户标识(软删除),未删除时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "identity_users", + type: "timestamp with time zone", + nullable: true, + comment: "软删除时间(UTC),未删除时为 null。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "identity_users", + type: "uuid", + nullable: true, + comment: "创建人用户标识,匿名或系统操作时为 null。", + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "identity_users", + type: "timestamp with time zone", + nullable: false, + comment: "创建时间(UTC)。", + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); + + migrationBuilder.AlterColumn( + name: "Avatar", + table: "identity_users", + type: "character varying(256)", + maxLength: 256, + nullable: true, + comment: "头像地址。", + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Account", + table: "identity_users", + type: "character varying(64)", + maxLength: 64, + nullable: false, + comment: "登录账号。", + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64); + + migrationBuilder.AlterColumn( + name: "Id", + table: "identity_users", + type: "uuid", + nullable: false, + comment: "实体唯一标识。", + oldClrType: typeof(Guid), + oldType: "uuid"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterTable( + name: "mini_users", + oldComment: "小程序用户实体。"); + + migrationBuilder.AlterTable( + name: "identity_users", + oldComment: "管理后台账户实体(平台管理员、租户管理员或商户员工)。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "mini_users", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "mini_users", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "UnionId", + table: "mini_users", + type: "character varying(128)", + maxLength: 128, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldNullable: true, + oldComment: "微信 UnionId,可能为空。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "mini_users", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "OpenId", + table: "mini_users", + type: "character varying(128)", + maxLength: 128, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldComment: "微信 OpenId。"); + + migrationBuilder.AlterColumn( + name: "Nickname", + table: "mini_users", + type: "character varying(64)", + maxLength: 64, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldComment: "昵称。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "mini_users", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "mini_users", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "mini_users", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "mini_users", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Avatar", + table: "mini_users", + type: "character varying(256)", + maxLength: 256, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true, + oldComment: "头像地址。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "mini_users", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + + migrationBuilder.AlterColumn( + name: "UpdatedBy", + table: "identity_users", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "最后更新人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "UpdatedAt", + table: "identity_users", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "最近一次更新时间(UTC),从未更新时为 null。"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "identity_users", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "所属租户 ID。"); + + migrationBuilder.AlterColumn( + name: "Roles", + table: "identity_users", + type: "text", + nullable: false, + oldClrType: typeof(string), + oldType: "text", + oldComment: "角色集合。"); + + migrationBuilder.AlterColumn( + name: "Permissions", + table: "identity_users", + type: "text", + nullable: false, + oldClrType: typeof(string), + oldType: "text", + oldComment: "权限集合。"); + + migrationBuilder.AlterColumn( + name: "PasswordHash", + table: "identity_users", + type: "character varying(256)", + maxLength: 256, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldComment: "密码哈希。"); + + migrationBuilder.AlterColumn( + name: "MerchantId", + table: "identity_users", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "所属商户(平台管理员为空)。"); + + migrationBuilder.AlterColumn( + name: "DisplayName", + table: "identity_users", + type: "character varying(64)", + maxLength: 64, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldComment: "展示名称。"); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + table: "identity_users", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "删除人用户标识(软删除),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "DeletedAt", + table: "identity_users", + type: "timestamp with time zone", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldNullable: true, + oldComment: "软删除时间(UTC),未删除时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "identity_users", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true, + oldComment: "创建人用户标识,匿名或系统操作时为 null。"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "identity_users", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone", + oldComment: "创建时间(UTC)。"); + + migrationBuilder.AlterColumn( + name: "Avatar", + table: "identity_users", + type: "character varying(256)", + maxLength: 256, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(256)", + oldMaxLength: 256, + oldNullable: true, + oldComment: "头像地址。"); + + migrationBuilder.AlterColumn( + name: "Account", + table: "identity_users", + type: "character varying(64)", + maxLength: 64, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(64)", + oldMaxLength: 64, + oldComment: "登录账号。"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "identity_users", + type: "uuid", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid", + oldComment: "实体唯一标识。"); + } + } +} diff --git a/src/Infrastructure/TakeoutSaaS.Infrastructure/Identity/Migrations/IdentityDbContextModelSnapshot.cs b/src/Infrastructure/TakeoutSaaS.Infrastructure/Identity/Migrations/IdentityDbContextModelSnapshot.cs index 385d79c..1814980 100644 --- a/src/Infrastructure/TakeoutSaaS.Infrastructure/Identity/Migrations/IdentityDbContextModelSnapshot.cs +++ b/src/Infrastructure/TakeoutSaaS.Infrastructure/Identity/Migrations/IdentityDbContextModelSnapshot.cs @@ -26,58 +26,73 @@ namespace TakeoutSaaS.Infrastructure.Identity.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); b.Property("Account") .IsRequired() .HasMaxLength(64) - .HasColumnType("character varying(64)"); + .HasColumnType("character varying(64)") + .HasComment("登录账号。"); b.Property("Avatar") .HasMaxLength(256) - .HasColumnType("character varying(256)"); + .HasColumnType("character varying(256)") + .HasComment("头像地址。"); b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); b.Property("CreatedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); b.Property("DeletedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); b.Property("DeletedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); b.Property("DisplayName") .IsRequired() .HasMaxLength(64) - .HasColumnType("character varying(64)"); + .HasColumnType("character varying(64)") + .HasComment("展示名称。"); b.Property("MerchantId") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("所属商户(平台管理员为空)。"); b.Property("PasswordHash") .IsRequired() .HasMaxLength(256) - .HasColumnType("character varying(256)"); + .HasColumnType("character varying(256)") + .HasComment("密码哈希。"); b.Property("Permissions") .IsRequired() - .HasColumnType("text"); + .HasColumnType("text") + .HasComment("权限集合。"); b.Property("Roles") .IsRequired() - .HasColumnType("text"); + .HasColumnType("text") + .HasComment("角色集合。"); b.Property("TenantId") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); b.Property("UpdatedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); b.HasKey("Id"); @@ -86,53 +101,68 @@ namespace TakeoutSaaS.Infrastructure.Identity.Migrations b.HasIndex("TenantId", "Account") .IsUnique(); - b.ToTable("identity_users", (string)null); + b.ToTable("identity_users", null, t => + { + t.HasComment("管理后台账户实体(平台管理员、租户管理员或商户员工)。"); + }); }); modelBuilder.Entity("TakeoutSaaS.Domain.Identity.Entities.MiniUser", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("实体唯一标识。"); b.Property("Avatar") .HasMaxLength(256) - .HasColumnType("character varying(256)"); + .HasColumnType("character varying(256)") + .HasComment("头像地址。"); b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("创建时间(UTC)。"); b.Property("CreatedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("创建人用户标识,匿名或系统操作时为 null。"); b.Property("DeletedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("软删除时间(UTC),未删除时为 null。"); b.Property("DeletedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("删除人用户标识(软删除),未删除时为 null。"); b.Property("Nickname") .IsRequired() .HasMaxLength(64) - .HasColumnType("character varying(64)"); + .HasColumnType("character varying(64)") + .HasComment("昵称。"); b.Property("OpenId") .IsRequired() .HasMaxLength(128) - .HasColumnType("character varying(128)"); + .HasColumnType("character varying(128)") + .HasComment("微信 OpenId。"); b.Property("TenantId") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("所属租户 ID。"); b.Property("UnionId") .HasMaxLength(128) - .HasColumnType("character varying(128)"); + .HasColumnType("character varying(128)") + .HasComment("微信 UnionId,可能为空。"); b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp with time zone") + .HasComment("最近一次更新时间(UTC),从未更新时为 null。"); b.Property("UpdatedBy") - .HasColumnType("uuid"); + .HasColumnType("uuid") + .HasComment("最后更新人用户标识,匿名或系统操作时为 null。"); b.HasKey("Id"); @@ -141,7 +171,10 @@ namespace TakeoutSaaS.Infrastructure.Identity.Migrations b.HasIndex("TenantId", "OpenId") .IsUnique(); - b.ToTable("mini_users", (string)null); + b.ToTable("mini_users", null, t => + { + t.HasComment("小程序用户实体。"); + }); }); #pragma warning restore 612, 618 } diff --git a/src/Infrastructure/TakeoutSaaS.Infrastructure/Identity/Persistence/IdentityDesignTimeDbContextFactory.cs b/src/Infrastructure/TakeoutSaaS.Infrastructure/Identity/Persistence/IdentityDesignTimeDbContextFactory.cs index 48667fb..c18d179 100644 --- a/src/Infrastructure/TakeoutSaaS.Infrastructure/Identity/Persistence/IdentityDesignTimeDbContextFactory.cs +++ b/src/Infrastructure/TakeoutSaaS.Infrastructure/Identity/Persistence/IdentityDesignTimeDbContextFactory.cs @@ -1,5 +1,6 @@ using Microsoft.EntityFrameworkCore; using TakeoutSaaS.Infrastructure.Common.Persistence.DesignTime; +using TakeoutSaaS.Shared.Abstractions.Constants; using TakeoutSaaS.Shared.Abstractions.Security; using TakeoutSaaS.Shared.Abstractions.Tenancy; @@ -12,7 +13,7 @@ internal sealed class IdentityDesignTimeDbContextFactory : DesignTimeDbContextFactoryBase { public IdentityDesignTimeDbContextFactory() - : base("TAKEOUTSAAS_IDENTITY_CONNECTION", "takeout_saas_identity") + : base(DatabaseConstants.IdentityDataSource, "TAKEOUTSAAS_IDENTITY_CONNECTION") { }