pbl_domain_ext/sql/pbl_domain_ext.sql

31 lines
2.4 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- =====================================================================
-- pbl_domain_extM8— world/scene/entity 薄扩展
-- 权威 DDLprojects/pbls/docs/01-design/data-model.md §JJ1. pbl_domain_ref
-- 表总账projects/pbls/pbls_spec.json tables_by_module.pbl_domain_ext = 1
-- 铁律:不改 world / scene / entity 三张复用基表(零 ALTER、零侵入模块代码
-- =====================================================================
-- J1. pbl_domain_ref — world/scene/entity 薄扩展关联ref_type + ref_id 唯一)
CREATE TABLE IF NOT EXISTS pbl_domain_ref (
id BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键',
tenant_id VARCHAR(64) NOT NULL COMMENT '租户ID基表无租户列PBL 多租户隔离由本表补齐)',
ref_type VARCHAR(32) NOT NULL COMMENT 'appcodes:pbl_domain_ref_type(world/scene/entity)',
ref_id BIGINT NOT NULL COMMENT '复用基表记录IDworld.id / scene.id / entity.id',
blueprint_id VARCHAR(64) DEFAULT NULL COMMENT '关联蓝图IDpbl_blueprintcompiler apply 后回写)',
class_id VARCHAR(64) DEFAULT NULL COMMENT '关联教学班IDpbl_governance.pbl_class',
team_id VARCHAR(64) DEFAULT NULL COMMENT '关联团队IDpbl_governance.pbl_team共享世界分组',
ext JSON DEFAULT NULL COMMENT '扩展属性JSON薄扩展附加维度不改基表',
is_deleted TINYINT NOT NULL DEFAULT 0 COMMENT '软删标记0=有效 1=已解绑unbind_ref 置 1',
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (id),
UNIQUE KEY uk_pbl_domain_ref (tenant_id, ref_type, ref_id),
KEY idx_pbl_domain_ref_bp (tenant_id, blueprint_id),
KEY idx_pbl_domain_ref_class (tenant_id, class_id),
KEY idx_pbl_domain_ref_team (tenant_id, team_id),
KEY idx_pbl_domain_ref_type (ref_type, ref_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='world/scene/entity 薄扩展关联表M8不改基表';
-- 编码ref_type 取值受 appcodes:pbl_domain_ref_type 约束world/scene/entity
-- 由 pbl_appcodes 模块幂等注入,本模块不重复写入编码表。