在前后端开发联调前 的提交20260223

This commit is contained in:
Neo
2026-02-23 23:02:20 +08:00
parent 254ccb1e77
commit fafc95e64c
1142 changed files with 10366960 additions and 36957 deletions

View File

@@ -0,0 +1,90 @@
"""
整理 apps/etl/connectors/feiqiu/docs/database/ 下的过时文档。
- 归档changes/ 下的变更记录、已删除表的 BD_manual、过时的 DDL 对比报告、过时的 overview 数据字典
- 保留:当前有效的 ODS/DWD/DWS/ETL_Admin BD_manualmain/ 和 Ex/、mappings/
用法cd C:\\NeoZQYY && python scripts/ops/_archive_etl_db_docs.py
"""
import shutil
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent.parent
ETL_DB_DOCS = ROOT / "apps" / "etl" / "connectors" / "feiqiu" / "docs" / "database"
ARCHIVE = ETL_DB_DOCS / "_archived"
# ── 需要归档的文件 ────────────────────────────────────────────────────────
FILES_TO_ARCHIVE = []
# 1. 所有 changes/ 目录下的 .md 文件(变更记录,已吸收进新 DDL 基线)
for changes_dir in ETL_DB_DOCS.rglob("changes"):
if changes_dir.is_dir():
for f in changes_dir.glob("*.md"):
FILES_TO_ARCHIVE.append(f)
# 2. 过时的 DDL 对比报告
ddl_compare = ETL_DB_DOCS / "ddl_compare_results.md"
if ddl_compare.exists():
FILES_TO_ARCHIVE.append(ddl_compare)
# 3. overview/ 下的数据字典(引用旧 DDL 路径,已过时)
overview_dir = ETL_DB_DOCS / "overview"
if overview_dir.exists():
for f in overview_dir.glob("*.md"):
FILES_TO_ARCHIVE.append(f)
# 4. 已删除表的 BD_manualassistant_abolish 清理后这些表不存在了)
DELETED_TABLE_DOCS = [
"DWD/main/BD_manual_dwd_assistant_trash_event.md",
"DWD/Ex/BD_manual_dwd_assistant_trash_event_ex.md",
"ODS/main/BD_manual_assistant_cancellation_records.md",
# ODS mappings 中对应的映射文档
"ODS/mappings/mapping_GetAbolitionAssistant_assistant_cancellation_records.md",
]
for rel in DELETED_TABLE_DOCS:
p = ETL_DB_DOCS / rel
if p.exists():
FILES_TO_ARCHIVE.append(p)
def main():
if not FILES_TO_ARCHIVE:
print("没有需要归档的文件。")
return
ARCHIVE.mkdir(parents=True, exist_ok=True)
moved = []
for src in FILES_TO_ARCHIVE:
# 保留相对于 ETL_DB_DOCS 的路径结构
rel = src.relative_to(ETL_DB_DOCS)
dest = ARCHIVE / rel
dest.parent.mkdir(parents=True, exist_ok=True)
shutil.move(str(src), str(dest))
moved.append(str(rel))
# 清理空的 changes/ 和 overview/ 目录(只剩 .gitkeep 的保留)
for d in ETL_DB_DOCS.rglob("changes"):
if d.is_dir():
remaining = [f for f in d.iterdir() if f.name != ".gitkeep"]
if not remaining:
gk = d / ".gitkeep"
if not gk.exists():
gk.touch()
if overview_dir.exists():
remaining = [f for f in overview_dir.iterdir() if f.name != ".gitkeep"]
if not remaining:
gk = overview_dir / ".gitkeep"
if not gk.exists():
gk.touch()
print(f"归档目录:{ARCHIVE}")
print(f"已归档 {len(moved)} 个文件:")
for f in moved:
print(f"{f}")
if __name__ == "__main__":
main()