在准备环境前提交次全部更改。

This commit is contained in:
Neo
2026-02-19 08:35:13 +08:00
parent ded6dfb9d8
commit 4eac07da47
1387 changed files with 6107191 additions and 33002 deletions

View File

@@ -0,0 +1,135 @@
- [P20260215-215917] 2026-02-15 21:59:17 +0800
- summary: CONTEXT TRANSFER: We are continuing a conversation that had gotten too long. Here is a summary: --- ## TASK 1: 审查 db 目录并…
- prompt:
```text
CONTEXT TRANSFER: We are continuing a conversation that had gotten too long. Here is a summary:
---
## TASK 1: 审查 db 目录并创建/完善数据库结构 + 全项目 schema 引用迁移
**STATUS**: done
**USER QUERIES**: 1 ("审查db目录并更新/建立相应数据库和数据库的结构属性等内容"), 2 ("继续,完成后,本项目所有连接配置,各种相关的业务代码也需要处理")
**DETAILS**:
- 创建 `etl_feiqiu` 和 `zqyy_app` 数据库(通过 dblink
- etl_feiqiu 六层 schema DDL 全部执行成功meta/ods/dwd/core/dws/app
- zqyy_app 11 表 + 种子数据全部成功
- 应用角色:`app_reader`(密码:`AppR3ad_2026!`)、`app_user`(密码:`AppUs3r_2026!`
- FDW 跨库映射完成
- 全项目 schema 引用迁移完成450+ 处替换):`billiards_ods` → `ods`, `billiards_dwd` → `dwd`, `billiards_dws` → `dws`, `etl_admin` → `meta`
- 使用 `scripts/fix_schema_refs.py` 批量替换工具完成
- 所有运行时代码ETL tasks/orchestration/quality/scripts、后端 app/services、GUI已清理
- 测试 fixture 中的旧 schema 名保留(测试 DDL 解析器能力)
- 旧 DDL 文件、审计日志、迁移历史文档中的旧名保留
**FILEPATHS**: `scripts/fix_schema_refs.py`, `scripts/batch_schema_rename.py`
---
## TASK 2: 从旧库迁移数据到新库 + 索引迁移 + ANALYZE
**STATUS**: in-progress
**USER QUERIES**: 3 ("遍历新库和旧库,迁移下数据。以及所有设置,如索引等方面")
**DETAILS**:
### 数据迁移状态(全部完成):
- 旧库 `LLZQ-test`schema: `billiards_ods`/`billiards_dwd`/`billiards_dws`/`etl_admin`)→ 新库 `etl_feiqiu`schema: `ods`/`dwd`/`dws`/`meta`
- 使用 `scripts/migrate_data.py` 通过 psycopg2 COPY 协议跨库迁移
- ODS 23 表全部一致(行数精确匹配)
- DWD 40 表全部一致
- DWS 数据已迁移(有数据的表:`cfg_index_parameters` 127行, `dws_assistant_daily_detail` 5276行, `dws_finance_daily_summary` 210行, `dws_index_percentile_history` 80行, `dws_member_assistant_intimacy` 219行, `dws_member_newconv_index` 49行, `dws_member_visit_detail` 4398行, `dws_member_winback_index` 122行
- meta 3 表已迁移(`etl_cursor` 44行, `etl_run` 8726行, `etl_task` 53行 vs 源49行 — 新库种子数据多4条正常
### 索引迁移状态:
- ODS 索引46/46 全部成功
- DWD 索引:已迁移(具体数量在输出被截断前未完整显示,但脚本已执行)
- DWS 索引59/67 成功8 个失败(都是物化视图 `mv_dws_*` 的索引,因为新库没有这些物化视图表)
- meta 索引0/0无自定义索引
### 未完成项:
1. **ANALYZE 未执行** — `migrate_data.py` 在 ANALYZE 步骤因 `set_session cannot be used inside a transaction` 错误失败。`migrate_fix_remaining.py` 也有同样问题。
2. **物化视图未迁移** — 旧库 DWS 有 8 个物化视图(`mv_dws_assistant_daily_detail_l1~l4`, `mv_dws_finance_daily_summary_l1~l4`),新库没有创建这些物化视图,导致 8 个索引创建失败。需要在新库创建这些物化视图。
3. **最终验证未完成** — `migrate_fix_remaining.py` 的最终验证部分未执行到(被 ANALYZE 错误中断)
### 数据库连接信息:
- Host: `100.64.0.4`, Port: `5432`, User: `local-Python`, Password: `Neo-local-1991125`
- MCP postgres 工具当前连接的是旧库 `LLZQ-test`
- 新库操作通过 dblink 或 psycopg2 脚本
**NEXT STEPS**:
1. 修复 ANALYZE — 在新库 `etl_feiqiu` 上执行 `ANALYZE` 更新统计信息(需要先 commit/rollback 当前事务再设 autocommit=True或用 dblink 执行)
2. 创建物化视图 — 查看旧库 8 个 `mv_dws_*` 物化视图的定义,在新库重建(替换 schema 名)
3. 运行最终验证 — 对比所有有数据表的行数确认一致
4. 考虑是否需要更新 MCP postgres 配置指向新库 `etl_feiqiu`
**FILEPATHS**: `scripts/migrate_data.py`, `scripts/migrate_fix_remaining.py`
---
## TASK 3: 审计(/audit
**STATUS**: not-started
**DETAILS**: governance 规则要求对高风险变更运行 `/audit`。本次变更涉及大量 `tasks/`、`orchestration/`、`quality/`、`config/`、后端 `app/services/`、DB schema 变更,属于高风险。用户需手动触发。
---
## USER CORRECTIONS AND INSTRUCTIONS:
- 所有说明性文字使用简体中文
- 密码由 agent 设置(`app_reader`: `AppR3ad_2026!`, `app_user`: `AppUs3r_2026!`),用户之后自行修改
- 可以直接执行 SQL 指令(通过 MCP postgres 工具,当前连接 `LLZQ-test`,新库操作通过 dblink
- `local-Python` 用户是超级用户
- MCP 工具在事务块中运行,无法直接 `CREATE DATABASE`,需通过 dblink 绕过
- 系统没有 `psql` 命令行工具,但有 `psycopg2` Python 包可用
- shell cwd 可能不在项目根目录,执行 Python 脚本需用绝对路径 `C:\NeoZQYY\...`
- Windows 控制台需要 `$env:PYTHONIOENCODING="utf-8"` 或 `sys.stdout.reconfigure(encoding="utf-8")` 处理中文输出
- 旧 DDL 文件(如 `schema_etl_admin.sql`)保留作为历史参考,不修改
- 审计日志和迁移历史文档中的旧 schema 名保留原样
- 测试代码中的 fixture SQL 使用旧 schema 名是测试 DDL 解析器能力,可以保留不改
- `validate_bd_manual.py` 中的 `ETL_Admin` 是文档目录层名称,不是数据库 schema 名
- 变更涉及 DB schema属于高风险操作完成后需要运行 `/audit`
## Files to read
- `scripts/migrate_data.py`
- `scripts/migrate_fix_remaining.py`
- `.env`
USER QUERIES(most recent first):
1. 遍历新库和旧库,迁移下数据。以及所有设置,如索引等方面。
2. Output:
Command executed successfully with no output.
Exit Code: 0
3. Output:
Command executed successfully with no output.
Exit Code: 0
4. 遍历新库和旧库,迁移下数据。以及所有设置,如索引等方面。
5. Output:
Hook execution failed with exit code 1.
Error output:
[AUDIT REMINDER] Pending audit detected (root-file, dir:backend, dir:etl, dir:db, db-schema-change). Run /audit (Manual: Run /audit hook) to sync docs & write audit artifacts. (rate limit: 15min)
Exit Code: 1
6. Output:
Command executed successfully with no output.
Exit Code: 0
7. Output:
Command executed successfully with no output.
Exit Code: 0
---
METADATA:
The previous conversation had 4 messages.
INSTRUCTIONS:
Continue working until the user query has been fully addressed. Do not ask for clarification - proceed with the work based on the context provided.
IMPORTANT: you need to read from the files to Read section