defupgrade()->None:# MySQL 8.0 不支持 DROP INDEX IF EXISTS / DROP COLUMN IF EXISTSop.drop_index("idx_storage_parent",table_name="storage_objects")op.drop_column("storage_objects","parent_object_id")defdowngrade()->None:op.add_column("storage_objects",sa.Column("parent_object_id",mysql.CHAR(length=26),nullable=True),)op.create_index("idx_storage_parent","storage_objects",["parent_object_id"],unique=False)
注意 MySQL 8.0 限制: 不要用 IF EXISTS / IF NOT EXISTS 标志,虽然 Alembic 暴露这些参数,但 MySQL 不支持(Alembic 会发出原生 SQL 报错)。
Applied migration f7a8b9c0d1e2. DB at head. TABLE COMMENT updated. 43/43 tests pass.
Codex review (deepseek-v4-flash, danger-full-access, on-request): 1 low finding fixed (model comment now reaches DB via ALTER TABLE ... COMMENT), 1 informational note left (downgrade column-order, no functional impact).
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
背景
storage_objects.parent_object_id列和idx_storage_parent索引是死代码:grep parent_object_id只有 4 处出现:migrations/.../e1f2a3b4c5d6_rebuild_baseline.py:337, 357和common/db/models/storage.py:23, 89relative_pathmaterialized path 维护(backend/src/backend/scripts.py:list_workspace_tree,list_workspace_directories)保留这个列会让后来人基于它写错误查询(就像本次会话已发生的:用户曾提议建邻接表方案,正是基于这个误导性列)。
改动
1. 写迁移 ——
migrations/versions/新迁移文件,根据下一个 revision ID 递增:
注意 MySQL 8.0 限制: 不要用
IF EXISTS/IF NOT EXISTS标志,虽然 Alembic 暴露这些参数,但 MySQL 不支持(Alembic 会发出原生 SQL 报错)。2. 改模型注释 ——
common/src/common/db/models/storage.py在
StorageObjects类的__table_args__注释里把"邻接表"幻觉掐死:3. 验证
StorageObjects(parent_object_id=...)的,需要清理list_workspace_tree/list_workspace_directories/list_scripts三个端点的 smoke test,确认没回归不做什么
relative_path—— materialized path 是唯一真相path_hash/idx_storage_workspace_path—— 这两个被 LIKE prefix 查询服务,真在用关联
Task: gpm8lz9z9h59siarlapfekmf
tao.chen commented:
Applied migration
f7a8b9c0d1e2. DB at head. TABLE COMMENT updated. 43/43 tests pass.Codex review (deepseek-v4-flash, danger-full-access, on-request): 1 low finding fixed (model comment now reaches DB via
ALTER TABLE ... COMMENT), 1 informational note left (downgrade column-order, no functional impact).Next: #34 (listScripts parent_path filter).