Close DDD refactor and remove generated asset proxy
This commit is contained in:
@@ -22,15 +22,30 @@ spacetime sql <db> "SELECT * FROM custom_world_gallery_entry"
|
||||
|
||||
| 领域 | 表 |
|
||||
| --- | --- |
|
||||
| 迁移权限 | `database_migration_operator` |
|
||||
| 认证 | `auth_store_snapshot`, `user_account`, `auth_identity`, `refresh_session` |
|
||||
| 运行时档案 | `runtime_setting`, `runtime_snapshot`, `user_browse_history`, `profile_dashboard_state`, `profile_wallet_ledger`, `profile_redeem_code`, `profile_redeem_code_usage`, `profile_played_world`, `profile_save_archive` |
|
||||
| 运行时档案 | `runtime_setting`, `runtime_snapshot`, `user_browse_history`, `profile_dashboard_state`, `profile_wallet_ledger`, `profile_redeem_code`, `profile_redeem_code_usage`, `profile_invite_code`, `profile_referral_relation`, `profile_played_world`, `profile_membership`, `profile_recharge_order`, `profile_save_archive` |
|
||||
| RPG 运行时 | `story_session`, `story_event`, `npc_state`, `inventory_slot`, `battle_state`, `treasure_record`, `quest_record`, `quest_log`, `player_progression`, `chapter_progression` |
|
||||
| 世界创作 | `custom_world_profile`, `custom_world_session`, `custom_world_agent_session`, `custom_world_agent_message`, `custom_world_agent_operation`, `custom_world_draft_card`, `custom_world_gallery_entry` |
|
||||
| 拼图 | `puzzle_agent_session`, `puzzle_agent_message`, `puzzle_work_profile`, `puzzle_event`, `puzzle_runtime_run`, `puzzle_leaderboard_entry` |
|
||||
| 大鱼吃小鱼 | `big_fish_creation_session`, `big_fish_agent_message`, `big_fish_asset_slot`, `big_fish_event`, `big_fish_runtime_run` |
|
||||
| 资产 | `asset_object`, `asset_entity_binding` |
|
||||
| 资产 | `asset_object`, `asset_entity_binding`, `asset_event` |
|
||||
| AI 任务 | `ai_task`, `ai_task_stage`, `ai_text_chunk`, `ai_result_reference`, `ai_task_event` |
|
||||
|
||||
## 迁移权限表
|
||||
|
||||
### `database_migration_operator`
|
||||
|
||||
- 作用:数据库迁移操作员授权表,用于限制导出、导入和增量导入等 private 表迁移能力,避免任意登录身份读取或覆盖全库真相。
|
||||
- 结构:`operator_identity PK: Identity`, `created_at: Timestamp`, `created_by: Identity`, `note: String`。
|
||||
- 索引:主键 `operator_identity`。
|
||||
- 迁移说明:该表是迁移权限本身,不纳入 `migration.rs` 的业务表导出白名单。
|
||||
|
||||
```sql
|
||||
SELECT * FROM database_migration_operator;
|
||||
SELECT * FROM database_migration_operator WHERE operator_identity = '<identity>';
|
||||
```
|
||||
|
||||
## 认证表
|
||||
|
||||
### `auth_store_snapshot`
|
||||
@@ -154,6 +169,29 @@ SELECT * FROM profile_redeem_code_usage WHERE code = '<CODE>';
|
||||
SELECT * FROM profile_redeem_code_usage WHERE user_id = '<user_id>';
|
||||
```
|
||||
|
||||
### `profile_invite_code`
|
||||
|
||||
- 作用:用户邀请中心的邀请码主表,保存用户当前稳定邀请码。
|
||||
- 结构:`user_id PK: String`, `invite_code: String`, `created_at: Timestamp`, `updated_at: Timestamp`。
|
||||
- 索引:主键 `user_id`,唯一索引 `invite_code`。
|
||||
|
||||
```sql
|
||||
SELECT * FROM profile_invite_code WHERE user_id = '<user_id>';
|
||||
SELECT * FROM profile_invite_code WHERE invite_code = '<invite_code>';
|
||||
```
|
||||
|
||||
### `profile_referral_relation`
|
||||
|
||||
- 作用:邀请关系表,记录被邀请人与邀请人之间的一次性绑定关系,以及双方奖励是否已发放。
|
||||
- 结构:`invitee_user_id PK: String`, `inviter_user_id: String`, `invite_code: String`, `inviter_reward_granted: bool`, `invitee_reward_granted: bool`, `bound_at: Timestamp`。
|
||||
- 索引:`inviter_user_id`, `(inviter_user_id, bound_at)`。
|
||||
|
||||
```sql
|
||||
SELECT * FROM profile_referral_relation WHERE invitee_user_id = '<invitee_user_id>';
|
||||
SELECT * FROM profile_referral_relation WHERE inviter_user_id = '<inviter_user_id>';
|
||||
SELECT * FROM profile_referral_relation WHERE inviter_user_id = '<inviter_user_id>' ORDER BY bound_at DESC;
|
||||
```
|
||||
|
||||
### `profile_played_world`
|
||||
|
||||
- 作用:记录用户玩过的世界及最后游玩时间,用于个人页历史和继续游戏入口。
|
||||
@@ -166,6 +204,27 @@ SELECT * FROM profile_played_world WHERE user_id = '<user_id>' AND world_key = '
|
||||
SELECT * FROM profile_played_world WHERE user_id = '<user_id>' ORDER BY last_played_at DESC;
|
||||
```
|
||||
|
||||
### `profile_membership`
|
||||
|
||||
- 作用:用户会员状态表,保存会员状态、档位、起止时间和最近更新时间。
|
||||
- 结构:`user_id PK: String`, `status: RuntimeProfileMembershipStatus`, `tier: RuntimeProfileMembershipTier`, `started_at: Timestamp`, `expires_at: Timestamp`, `updated_at: Timestamp`。
|
||||
- 索引:主键 `user_id`。
|
||||
|
||||
```sql
|
||||
SELECT * FROM profile_membership WHERE user_id = '<user_id>';
|
||||
```
|
||||
|
||||
### `profile_recharge_order`
|
||||
|
||||
- 作用:充值订单表,记录用户购买叙世币或会员的订单、支付渠道、支付时间、积分变更和会员到期时间。
|
||||
- 结构:`order_id PK: String`, `user_id: String`, `product_id: String`, `product_title: String`, `kind: RuntimeProfileRechargeProductKind`, `amount_cents: u64`, `status: RuntimeProfileRechargeOrderStatus`, `payment_channel: String`, `paid_at: Timestamp`, `created_at: Timestamp`, `points_delta: i64`, `membership_expires_at: Option<Timestamp>`。
|
||||
- 索引:`user_id`, `(user_id, created_at)`。
|
||||
|
||||
```sql
|
||||
SELECT * FROM profile_recharge_order WHERE order_id = '<order_id>';
|
||||
SELECT * FROM profile_recharge_order WHERE user_id = '<user_id>' ORDER BY created_at DESC;
|
||||
```
|
||||
|
||||
### `profile_save_archive`
|
||||
|
||||
- 作用:用户存档列表,保存世界信息、封面、当前状态 JSON 和剧情 JSON。
|
||||
@@ -537,6 +596,19 @@ SELECT * FROM asset_entity_binding WHERE entity_kind = '<entity_kind>' AND entit
|
||||
SELECT * FROM asset_entity_binding WHERE asset_object_id = '<asset_object_id>';
|
||||
```
|
||||
|
||||
### `asset_event`
|
||||
|
||||
- 作用:资产事件表,目前记录对象确认和实体槽位绑定变更事实,供订阅端、BFF 或审计流程感知资产主链变化;正式资产状态仍以 `asset_object` 和 `asset_entity_binding` 为准。
|
||||
- 可见性:`public event`。
|
||||
- 结构:`event_id PK: String`, `asset_object_id: String`, `binding_id: Option<String>`, `event_kind: AssetEventKind`, `asset_kind: String`, `owner_user_id: Option<String>`, `profile_id: Option<String>`, `entity_kind: Option<String>`, `entity_id: Option<String>`, `slot: Option<String>`, `occurred_at: Timestamp`。
|
||||
- 索引:`asset_object_id`, `owner_user_id`, `profile_id`。
|
||||
|
||||
```sql
|
||||
SELECT * FROM asset_event WHERE asset_object_id = '<asset_object_id>' ORDER BY occurred_at ASC;
|
||||
SELECT * FROM asset_event WHERE owner_user_id = '<user_id>' ORDER BY occurred_at DESC;
|
||||
SELECT * FROM asset_event WHERE profile_id = '<profile_id>' ORDER BY occurred_at DESC;
|
||||
```
|
||||
|
||||
## AI 任务表
|
||||
|
||||
### `ai_task`
|
||||
@@ -599,5 +671,6 @@ SELECT * FROM ai_task_event WHERE owner_user_id = '<user_id>' ORDER BY occurred_
|
||||
|
||||
## 当前维护风险
|
||||
|
||||
- `story_session`、`story_event`、`npc_state`、`inventory_slot`、`battle_state`、`treasure_record`、`quest_record`、`quest_log`、`player_progression`、`chapter_progression` 在 `src/lib.rs` 与 `src/gameplay/mod.rs` 都能看到表定义。当前编译入口以 `src/lib.rs` 为准;后续完成拆分时,需要删除重复定义或正式挂载子模块,并同步更新本文。
|
||||
- `custom_world/*` 子模块中也保留了一份表骨架;当前生成绑定与 `src/lib.rs` 对齐,包含 `public_work_code`、`author_public_user_code` 和 `custom_world_gallery_entry.public_work_code` 索引。维护时不要只看子模块文件。
|
||||
- `scripts/check-server-rs-ddd-boundaries.mjs` 已检查 `spacetime-module/src/**` 中的表定义、`migration.rs` 白名单和本文目录项是否一致;新增或删除表后必须先让该检查通过。
|
||||
- `database_migration_operator` 是迁移权限表,不导出到业务迁移包;除此之外的业务表都必须进入 `migration.rs`。
|
||||
- `spacetime-client/src/module_bindings/**` 是生成物,表、reducer 或 procedure 发生 shape 变化后必须通过 `npm.cmd run spacetime:generate -- --rust-only` 或对应 SpacetimeDB CLI 流程重新生成,不要手写修改。
|
||||
|
||||
Reference in New Issue
Block a user