feat: 统一模板 segments 数据源到 template_clip_configs #1579

Merged
auto-approve-bot merged 1 commits from feat/unify-template-segments into develop 2026-08-31 22:26:03 +08:00
Owner

背景

项目有两套模板数据表:

  • 旧系统:templates + template_segments(前端模板列表读取)
  • 新编辑器:edit_templates + template_clip_configs(编辑器发布写入)

两套数据不互通,导致前端读到的 segments 为空。

改动

  • template_repository.py:所有 segments 读写统一改为操作 template_clip_configs
    • list_segments:优先读 template_clip_configs,为空时回退读旧 template_segments(兼容历史数据)
    • create_segments:写入 template_clip_configsmaterial_type 保存在 config JSON 字段
    • delete:同时清理两张表
    • copy_template:从 template_clip_configs 复制
  • Alembic migration 060:一次性迁移 template_segments 中的孤儿数据到 template_clip_configs
  • 10 个新测试覆盖统一后的行为

不改的

  • 前端代码不动
  • 编辑器草稿/发布流程不动
  • 旧表不 DROP(保留历史数据)
  • API 响应格式不变(segments 字段名、结构完全兼容)
## 背景 项目有两套模板数据表: - 旧系统:`templates` + `template_segments`(前端模板列表读取) - 新编辑器:`edit_templates` + `template_clip_configs`(编辑器发布写入) 两套数据不互通,导致前端读到的 segments 为空。 ## 改动 - `template_repository.py`:所有 segments 读写统一改为操作 `template_clip_configs` 表 - `list_segments`:优先读 `template_clip_configs`,为空时回退读旧 `template_segments`(兼容历史数据) - `create_segments`:写入 `template_clip_configs`,`material_type` 保存在 `config` JSON 字段 - `delete`:同时清理两张表 - `copy_template`:从 `template_clip_configs` 复制 - Alembic migration 060:一次性迁移 `template_segments` 中的孤儿数据到 `template_clip_configs` - 10 个新测试覆盖统一后的行为 ## 不改的 - 前端代码不动 - 编辑器草稿/发布流程不动 - 旧表不 DROP(保留历史数据) - API 响应格式不变(segments 字段名、结构完全兼容)

🚀 预览环境已部署

项目 详情
PR号 #1579
预览链接 https://pr-1579.preview.xiaoxiajianji.com
API环境 staging

💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。

🔄 每次提交新代码后预览环境会自动更新。

🗑️ PR 关闭或合并后,预览环境会自动清理。

🚀 **预览环境已部署** | 项目 | 详情 | |------|------| | PR号 | #1579 | | 预览链接 | [https://pr-1579.preview.xiaoxiajianji.com](https://pr-1579.preview.xiaoxiajianji.com) | | API环境 | staging | > 💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。 > > 🔄 每次提交新代码后预览环境会自动更新。 > > 🗑️ PR 关闭或合并后,预览环境会自动清理。
xiaoxia force-pushed feat/unify-template-segments from 2b3f1801d4 to a99c0515ea 2026-08-31 17:52:53 +08:00 Compare
auto-approve-bot approved these changes 2026-08-31 18:15:31 +08:00
auto-approve-bot left a comment
Collaborator

CI全绿,自动审批通过。

CI全绿,自动审批通过。
auto-approve-bot approved these changes 2026-08-31 18:15:31 +08:00
auto-approve-bot left a comment
Collaborator

CI全绿,自动审批通过。

CI全绿,自动审批通过。
xiaoxia force-pushed feat/unify-template-segments from b7401fcffa to b3f608efee 2026-08-31 18:17:12 +08:00 Compare
xiaoxia force-pushed feat/unify-template-segments from 8940f580c9 to 67c596c3eb 2026-08-31 18:45:23 +08:00 Compare
xiaoxia force-pushed feat/unify-template-segments from 320b2fcedb to 5224870f8d 2026-08-31 18:57:52 +08:00 Compare
xiaoxia force-pushed feat/unify-template-segments from 8a46ef49b9 to 5224870f8d 2026-08-31 19:12:58 +08:00 Compare
xiaoxia added 1 commit 2026-08-31 19:58:53 +08:00
feat: 统一模板 segments 数据源为 template_clip_configs
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 1s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 1s
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Validate - Style (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Security (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Has been cancelled
CI/CD Pipeline / Unit Tests (pull_request) Has been cancelled
CI/CD Pipeline / Integration Tests (pull_request) Has been cancelled
CI/CD Pipeline / Frontend Lint (pull_request) Has been cancelled
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been cancelled
CI/CD Pipeline / PR Build API Image (pull_request) Has been cancelled
CI/CD Pipeline / PR Build Web Image (pull_request) Has been cancelled
CI/CD Pipeline / PR Build Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Has been cancelled
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been cancelled
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been cancelled
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been cancelled
CI/CD Pipeline / Build Production API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been cancelled
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been cancelled
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / CI Gate (pull_request) Has been cancelled
AI Code Review / AI Code Review (pull_request) Has been cancelled
PR Automation / Auto Approve on CI Green (pull_request) Has been cancelled
PR Automation / Auto Merge on CI Green + Approved (pull_request) Has been cancelled
Preview Deploy / Deploy Preview Environment (pull_request) Has been cancelled
6e76b45d34
- list_segments/list_by_user 优先读 clip_configs,回退 template_segments
- create_segments 写入 clip_configs,material_type 存 config JSON
- copy_template 复用 create_segments,使用 created.id
- delete 复用 delete_segments_by_template 清理两张表
- migration 060: 方言感知(postgresql/mysql)一次性迁移历史数据
- 11 个新测试 + 120 个现有测试全部通过

Closes #1579
xiaoxia force-pushed feat/unify-template-segments from 303f544e41 to 6e76b45d34 2026-08-31 19:58:53 +08:00 Compare
xiaoxia force-pushed feat/unify-template-segments from 2b73655500 to 6e76b45d34 2026-08-31 20:45:51 +08:00 Compare
xiaoxia added 1 commit 2026-08-31 20:46:20 +08:00
chore: re-trigger CI (previous run had git-cache EOF infra failure)
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 1s
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 1s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 4m10s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 4m12s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 4m43s
AI Code Review / AI Code Review (pull_request) Successful in 4m52s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 6m27s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 7m27s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 19m8s
CI/CD Pipeline / Validate - Style (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Security (pull_request) Has been cancelled
CI/CD Pipeline / Unit Tests (pull_request) Has been cancelled
CI/CD Pipeline / Integration Tests (pull_request) Has been cancelled
CI/CD Pipeline / Build Production API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been cancelled
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / CI Gate (pull_request) Has been cancelled
a9438ed996
xiaoxia force-pushed feat/unify-template-segments from c3aecd7742 to a9438ed996 2026-08-31 21:07:28 +08:00 Compare
auto-approve-bot added 1 commit 2026-08-31 21:27:06 +08:00
style: auto-format with black + isort + prettier [skip ci-format-check]
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 1s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 1s
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 3m53s
AI Code Review / AI Code Review (pull_request) Successful in 6m8s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 5m19s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 6m57s
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 1m46s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 1m38s
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Validate - Style (pull_request) Successful in 10m33s
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 13m38s
CI/CD Pipeline / Validate - Security (pull_request) Successful in 24m6s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 37m13s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 48m43s
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Successful in 1s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 5m5s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 5m12s
6bf9eff604
Collaborator

代码审查结果 - PR #1579

⚠️ 问题(0个需要修改)

💡 建议(0个可选)


格式检查通过 | 逻辑审查通过 | 性能无问题


🤖 由 AI 代码审查机器人自动生成 | 2026-08-31 13:34:37 | 模型:

## 代码审查结果 - PR #1579 ### ⚠️ 问题(0个需要修改) ### 💡 建议(0个可选) --- ✅ 格式检查通过 | ✅ 逻辑审查通过 | ✅ 性能无问题 --- <sub>🤖 由 AI 代码审查机器人自动生成 | 2026-08-31 13:34:37 | 模型: </sub> <!-- AI_CODE_REVIEW_AUTO_COMMENT -->
auto-approve-bot merged commit 5ed2ee1192 into develop 2026-08-31 22:26:03 +08:00
auto-approve-bot deleted branch feat/unify-template-segments 2026-08-31 22:26:04 +08:00

🗑️ 预览环境已清理

PR #1579 已关闭或合并,对应的预览环境已被清理。

如有需要,可以重新打开 PR 来重新生成预览环境。

🗑️ **预览环境已清理** PR #1579 已关闭或合并,对应的预览环境已被清理。 > 如有需要,可以重新打开 PR 来重新生成预览环境。
Sign in to join this conversation.