- 卡片列表改为表格列表(10列),参考用户运营中心产品台账 - 数据库新增 priority + 5 个日期字段(start/plan/dev_done/test/launch) - 删除 owner/platform/feature_list 字段(migrate_drop_product_fields) - 日期内联编辑:5个日期列直接渲染 date input - 后端日期校验:4个时间不能早于启动时间;启动时间必填 - 详情页新增耗时统计区块(总/产品/研发/测试耗时) - 优先级和状态合并同一行 - 新增'未开始'状态 - 表格垂直居中对齐 - renderProducts 后重新初始化 lucide 图标
74 lines
2.6 KiB
Python
74 lines
2.6 KiB
Python
"""migrations/data_fixes.py — 数据修正迁移(修复脏数据、变更枚举值)"""
|
|
|
|
|
|
def migrate_fix_task_status():
|
|
"""修正 project_tasks 中非法的 status 值"""
|
|
from flask_app import db, _exec, mysql, logger
|
|
|
|
conn = db()
|
|
try:
|
|
fixes = [
|
|
"UPDATE project_tasks SET status='未开始' WHERE status='' OR status IS NULL",
|
|
"UPDATE project_tasks SET status='已结束' WHERE status='done'",
|
|
"UPDATE project_tasks SET status='进行中' WHERE status='验收中'",
|
|
]
|
|
for sql in fixes:
|
|
try:
|
|
cur = _exec(conn, sql)
|
|
affected = cur.rowcount
|
|
cur.close()
|
|
if affected:
|
|
print(f"[migrate] 修正 {affected} 条任务状态")
|
|
except mysql.connector.Error as e:
|
|
logger.warning(f"task status fix skipped: {e}")
|
|
conn.commit()
|
|
finally:
|
|
conn.close()
|
|
|
|
|
|
def migrate_rename_tenant():
|
|
"""工作台重命名:无界·无界 → 学会·无界"""
|
|
from flask_app import db, _exec, mysql
|
|
|
|
conn = db()
|
|
try:
|
|
tables = ["user_tenants", "sales_leads", "follow_up_records", "business_proposals",
|
|
"operation_projects", "product_versions", "finance_records", "project_tasks",
|
|
"project_finances"]
|
|
for table in tables:
|
|
try:
|
|
cur = _exec(conn, f"UPDATE {table} SET tenant='学会·无界' WHERE tenant='无界·无界'")
|
|
affected = cur.rowcount
|
|
cur.close()
|
|
if affected:
|
|
print(f"[migrate] {table}: {affected} 条记录 tenant 改为 '学会·无界'")
|
|
except mysql.connector.Error:
|
|
pass
|
|
conn.commit()
|
|
finally:
|
|
conn.close()
|
|
|
|
|
|
def migrate_drop_product_fields():
|
|
"""删除 product_versions 表的 owner / platform / feature_list 字段"""
|
|
from flask_app import db, mysql
|
|
|
|
conn = db()
|
|
try:
|
|
for col in ["owner", "platform", "feature_list"]:
|
|
cur = conn.cursor(dictionary=True)
|
|
cur.execute("SHOW COLUMNS FROM product_versions LIKE %s", (col,))
|
|
exists = cur.fetchone()
|
|
cur.close()
|
|
if exists:
|
|
try:
|
|
cur = conn.cursor()
|
|
cur.execute(f"ALTER TABLE product_versions DROP COLUMN {col}")
|
|
cur.close()
|
|
conn.commit()
|
|
print(f"[migrate] product_versions.{col} 列已删除")
|
|
except mysql.connector.Error as e:
|
|
print(f"[migrate] 删除 {col} 失败: {e}")
|
|
finally:
|
|
conn.close()
|