新增全局协作台账并统一工作台管理界面
新增与项目平级的协作台账,提供空白模板、独立账号授权和在线编辑。 复用共享库的访问权限与历史版本界面,拆分信息维护入口并统一工作台卡片样式。 补充在线文档字体构建支持、数据库表结构升级和回归测试。 不包含本地台账内容、账号授权记录或历史文件迁移数据。
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
"""Add global ledgers sharing the collaboration engine.
|
||||
|
||||
Revision ID: 20260903_01
|
||||
Revises: 20260716_05
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
revision = "20260903_01"
|
||||
down_revision = "20260716_05"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.alter_column("collaboration_files", "study_id", nullable=True)
|
||||
op.add_column("collaboration_files", sa.Column("scope", sa.String(16), nullable=False, server_default="PROJECT"))
|
||||
op.add_column("collaboration_files", sa.Column("ledger_key", sa.String(64), nullable=True))
|
||||
op.add_column("collaboration_files", sa.Column("description", sa.String(500), nullable=False, server_default=""))
|
||||
op.create_unique_constraint("uq_collaboration_file_ledger_key", "collaboration_files", ["ledger_key"])
|
||||
op.create_check_constraint(
|
||||
"ck_collaboration_file_scope", "collaboration_files",
|
||||
"(scope = 'PROJECT' AND study_id IS NOT NULL AND ledger_key IS NULL) OR "
|
||||
"(scope = 'LEDGER' AND study_id IS NULL AND folder_id IS NULL AND ledger_key IS NOT NULL "
|
||||
"AND file_type = 'cell' AND extension = 'xlsx' AND deleted_at IS NULL AND status IN ('ACTIVE', 'ARCHIVED'))",
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# Never discard retained ledger files, grants or history during rollback.
|
||||
if op.get_bind().scalar(sa.text("SELECT count(*) FROM collaboration_files WHERE scope = 'LEDGER'")):
|
||||
raise RuntimeError("已有全局台账,不能回滚台账迁移;请保留数据并使用前向修复")
|
||||
op.drop_constraint("ck_collaboration_file_scope", "collaboration_files", type_="check")
|
||||
op.drop_constraint("uq_collaboration_file_ledger_key", "collaboration_files", type_="unique")
|
||||
op.drop_column("collaboration_files", "description")
|
||||
op.drop_column("collaboration_files", "ledger_key")
|
||||
op.drop_column("collaboration_files", "scope")
|
||||
op.alter_column("collaboration_files", "study_id", nullable=False)
|
||||
Reference in New Issue
Block a user