补充生产初始化数据库导出实施计划
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
# 生产初始化数据库导出计划文档实施记录
|
||||
|
||||
## 本次改动
|
||||
|
||||
- 新增设计文档 `docs/superpowers/specs/2026-03-31-production-db-init-export-design.md`
|
||||
- 新增后端实施计划 `docs/superpowers/plans/2026-03-31-production-db-init-export-backend-plan.md`
|
||||
- 新增前端实施计划 `docs/superpowers/plans/2026-03-31-production-db-init-export-frontend-plan.md`
|
||||
|
||||
## 设计结论
|
||||
|
||||
- 最终交付物是单一可执行 SQL 文件
|
||||
- 基础部分直接复用 `sql/ry_20250522.sql`
|
||||
- 业务增量仅包含 `loan_pricing_workflow`、`model_corp_output_fields`、`model_retail_output_fields` 三张表结构
|
||||
- 不导出任何业务数据
|
||||
|
||||
## 说明
|
||||
|
||||
- 按仓库规范未开启 subagent
|
||||
- 本次阶段仅完成设计与实施计划编写,尚未开始生成最终 SQL 文件
|
||||
@@ -0,0 +1,238 @@
|
||||
# Production DB Init Export Backend Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED: Use superpowers:executing-plans to implement this plan in this repository. Do not use subagents. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** 产出一个可直接执行的生产初始化单文件 SQL,基于若依基础脚本补齐贷款定价 3 张业务表结构,且不包含任何业务数据。
|
||||
|
||||
**Architecture:** 直接复用 `sql/ry_20250522.sql` 作为若依基础内容来源,再从当前项目最终结构来源中抽取 `loan_pricing_workflow`、`model_corp_output_fields`、`model_retail_output_fields` 三张业务表结构,拼装为新的生产初始化总脚本。完成后通过静态检查和临时数据库导入验证,确认脚本既能完整建库建表,又不会写入业务数据。
|
||||
|
||||
**Tech Stack:** MySQL 5.7/8.0、SQL、shell、`mysql` 客户端、`rg`
|
||||
|
||||
---
|
||||
|
||||
### Task 1: 锁定业务表最终结构来源
|
||||
|
||||
**Files:**
|
||||
- Inspect: `sql/loan_pricing_schema_20260328.sql`
|
||||
- Inspect: `sql/loan_pricing_workflow.sql`
|
||||
- Inspect: `sql/model_corp.sql`
|
||||
- Inspect: `sql/model_retail.sql`
|
||||
- Inspect: `sql/add_missing_fields.sql`
|
||||
- Inspect: `sql/add_execute_rate_field.sql`
|
||||
- Inspect: `sql/fix_comments.sql`
|
||||
- Inspect: `sql/fix_comments_utf8.sql`
|
||||
- Inspect: `sql/fix_all_comments.sql`
|
||||
|
||||
- [ ] **Step 1: 比对 3 张业务表在各 SQL 文件中的定义**
|
||||
|
||||
Run: `rg -n "CREATE TABLE \`loan_pricing_workflow\`|CREATE TABLE \`model_corp_output_fields\`|CREATE TABLE \`model_retail_output_fields\`|ALTER TABLE \`loan_pricing_workflow\`|ALTER TABLE loan_pricing_workflow" sql/loan_pricing_schema_20260328.sql sql/loan_pricing_workflow.sql sql/model_corp.sql sql/model_retail.sql sql/add_missing_fields.sql sql/add_execute_rate_field.sql sql/fix_comments.sql sql/fix_comments_utf8.sql sql/fix_all_comments.sql`
|
||||
Expected: 能定位 3 张业务表的最终建表来源以及 `loan_pricing_workflow` 的后续字段修正脚本。
|
||||
|
||||
- [ ] **Step 2: 以 `loan_pricing_schema_20260328.sql` 作为最终结构主来源**
|
||||
|
||||
核对至少以下字段必须存在于最终结构中:
|
||||
|
||||
```sql
|
||||
`loan_term` varchar(50) DEFAULT NULL COMMENT '贷款期限',
|
||||
`is_tech_ent` varchar(10) DEFAULT NULL COMMENT '科技型企业: true/false(科技型企业最多下降5BP)',
|
||||
`is_green_loan` varchar(10) DEFAULT NULL COMMENT '绿色贷款: true/false(绿色贷款最多下降5BP)',
|
||||
`is_trade_construction` varchar(10) DEFAULT NULL COMMENT '贸易和建筑业企业标识: true/false(抵质押类上调20BP)',
|
||||
`loan_loop` varchar(10) DEFAULT NULL COMMENT '循环功能: true/false(贷款合同是否开通循环功能)',
|
||||
`id_num` varchar(100) DEFAULT NULL COMMENT '证件号码',
|
||||
`execute_rate` varchar(20) DEFAULT NULL COMMENT '执行利率(%)',
|
||||
```
|
||||
|
||||
Expected: `loan_pricing_schema_20260328.sql` 能完整反映当前 3 张业务表最终结构,不需要再从带数据文件中提取。
|
||||
|
||||
- [ ] **Step 3: 记录本次只导出结构、不导出业务数据的边界**
|
||||
|
||||
Run: `rg -n "INSERT INTO \`loan_pricing_workflow\`|INSERT INTO \`model_corp_output_fields\`|INSERT INTO \`model_retail_output_fields\`" sql/loan_pricing_required_data_20260328.sql`
|
||||
Expected: 仅在历史必要数据脚本中看到业务表插数语句,作为本次明确排除项。
|
||||
|
||||
- [ ] **Step 4: 提交本任务**
|
||||
|
||||
```bash
|
||||
git add docs/superpowers/plans/2026-03-31-production-db-init-export-backend-plan.md
|
||||
git commit -m "补充生产初始化数据库导出后端计划"
|
||||
```
|
||||
|
||||
### Task 2: 生成生产初始化总脚本
|
||||
|
||||
**Files:**
|
||||
- Create: `sql/loan_pricing_prod_init_20260331.sql`
|
||||
- Inspect: `sql/ry_20250522.sql`
|
||||
- Inspect: `sql/loan_pricing_schema_20260328.sql`
|
||||
|
||||
- [ ] **Step 1: 确认目标文件尚不存在,避免覆盖已有发布资产**
|
||||
|
||||
Run: `test ! -f sql/loan_pricing_prod_init_20260331.sql && echo "missing"`
|
||||
Expected: 输出 `missing`,说明目标文件可安全新建。
|
||||
|
||||
- [ ] **Step 2: 创建脚本头部说明和数据库上下文**
|
||||
|
||||
在新文件头部写入类似说明:
|
||||
|
||||
```sql
|
||||
-- 说明:
|
||||
-- 1. 本文件用于生产环境数据库初始化
|
||||
-- 2. 基于 sql/ry_20250522.sql 追加贷款定价业务表结构生成
|
||||
-- 3. 包含若依基础初始化数据,不包含任何贷款定价业务数据
|
||||
```
|
||||
|
||||
并补齐:
|
||||
|
||||
```sql
|
||||
CREATE DATABASE IF NOT EXISTS `loan-pricing` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
USE `loan-pricing`;
|
||||
```
|
||||
|
||||
- [ ] **Step 3: 追加若依基础脚本内容**
|
||||
|
||||
直接将 `sql/ry_20250522.sql` 的主体内容复制到目标文件数据库上下文之后,不新增、不删减其中的基础初始化数据。
|
||||
|
||||
- [ ] **Step 4: 追加 3 张业务表的最终 `DROP TABLE` 与 `CREATE TABLE`**
|
||||
|
||||
从 `sql/loan_pricing_schema_20260328.sql` 提取并追加以下 3 段:
|
||||
|
||||
```sql
|
||||
DROP TABLE IF EXISTS `loan_pricing_workflow`;
|
||||
CREATE TABLE `loan_pricing_workflow` (...);
|
||||
```
|
||||
|
||||
```sql
|
||||
DROP TABLE IF EXISTS `model_corp_output_fields`;
|
||||
CREATE TABLE `model_corp_output_fields` (...);
|
||||
```
|
||||
|
||||
```sql
|
||||
DROP TABLE IF EXISTS `model_retail_output_fields`;
|
||||
CREATE TABLE `model_retail_output_fields` (...);
|
||||
```
|
||||
|
||||
要求:
|
||||
- 保留最终字段定义和注释
|
||||
- 不带 `AUTO_INCREMENT=13`、`AUTO_INCREMENT=7` 这类依赖现存数据的值
|
||||
- 不带任何 `INSERT INTO` 业务数据
|
||||
|
||||
- [ ] **Step 5: 做静态完整性检查**
|
||||
|
||||
Run: `rg -n "loan_pricing_workflow|model_corp_output_fields|model_retail_output_fields|INSERT INTO \`loan_pricing_workflow\`|INSERT INTO \`model_corp_output_fields\`|INSERT INTO \`model_retail_output_fields\`" sql/loan_pricing_prod_init_20260331.sql`
|
||||
Expected: 能看到 3 张业务表的结构定义;看不到 3 张业务表的 `INSERT INTO`。
|
||||
|
||||
- [ ] **Step 6: 提交本任务**
|
||||
|
||||
```bash
|
||||
git add sql/loan_pricing_prod_init_20260331.sql
|
||||
git commit -m "新增生产初始化数据库脚本"
|
||||
```
|
||||
|
||||
### Task 3: 校验脚本范围与重复定义
|
||||
|
||||
**Files:**
|
||||
- Modify: `sql/loan_pricing_prod_init_20260331.sql`
|
||||
|
||||
- [ ] **Step 1: 检查 3 张业务表在目标文件中只定义一次**
|
||||
|
||||
Run: `python - <<'PY'\nfrom pathlib import Path\ntext = Path('sql/loan_pricing_prod_init_20260331.sql').read_text()\nfor name in ['loan_pricing_workflow','model_corp_output_fields','model_retail_output_fields']:\n print(name, text.count(f'CREATE TABLE `{name}`'))\nPY`
|
||||
Expected: 3 行输出都为 `1`。
|
||||
|
||||
- [ ] **Step 2: 检查目标文件未引入历史必要数据脚本中的业务插数**
|
||||
|
||||
Run: `rg -n "INSERT INTO \`loan_pricing_workflow\`|INSERT INTO \`model_corp_output_fields\`|INSERT INTO \`model_retail_output_fields\`|DELETE FROM \`loan_pricing_workflow\`|DELETE FROM \`model_corp_output_fields\`|DELETE FROM \`model_retail_output_fields\`" sql/loan_pricing_prod_init_20260331.sql`
|
||||
Expected: 无输出。
|
||||
|
||||
- [ ] **Step 3: 检查目标文件仍保留若依基础初始化数据**
|
||||
|
||||
Run: `rg -n "insert into sys_user values|insert into sys_role values|insert into sys_menu values" sql/loan_pricing_prod_init_20260331.sql`
|
||||
Expected: 能定位若依基础用户、角色、菜单初始化语句,说明基础初始化数据未被误删。
|
||||
|
||||
- [ ] **Step 4: 如静态检查发现重复或缺失,立即修正脚本**
|
||||
|
||||
只允许修正以下问题:
|
||||
|
||||
```sql
|
||||
-- 删除重复的业务表建表段
|
||||
-- 补回遗漏的 CREATE DATABASE / USE / DROP TABLE / CREATE TABLE
|
||||
-- 删除误写入的业务表 DELETE / INSERT
|
||||
```
|
||||
|
||||
- [ ] **Step 5: 提交本任务**
|
||||
|
||||
```bash
|
||||
git add sql/loan_pricing_prod_init_20260331.sql
|
||||
git commit -m "校验并修正生产初始化数据库脚本"
|
||||
```
|
||||
|
||||
### Task 4: 用临时数据库验证脚本可执行性
|
||||
|
||||
**Files:**
|
||||
- Modify: `sql/loan_pricing_prod_init_20260331.sql`
|
||||
- Create: `doc/implementation-report-2026-03-31-production-db-init-export-backend.md`
|
||||
|
||||
- [ ] **Step 1: 设置临时验证库环境变量**
|
||||
|
||||
在执行前准备:
|
||||
|
||||
```bash
|
||||
export DB_HOST=116.62.17.81
|
||||
export DB_PORT=3307
|
||||
export DB_USER=root
|
||||
export DB_PASSWORD='******'
|
||||
export VERIFY_DB=loan_pricing_prod_init_verify_20260331
|
||||
```
|
||||
|
||||
要求:
|
||||
- `DB_PASSWORD` 从现有环境配置读取后在当前 shell 设置
|
||||
- 不把密码写回仓库文件
|
||||
|
||||
- [ ] **Step 2: 创建临时验证库并导入脚本**
|
||||
|
||||
Run:
|
||||
|
||||
```bash
|
||||
MYSQL_PWD="$DB_PASSWORD" mysql -h "$DB_HOST" -P "$DB_PORT" -u "$DB_USER" -e "DROP DATABASE IF EXISTS \`$VERIFY_DB\`; CREATE DATABASE \`$VERIFY_DB\` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"
|
||||
perl -0pe "s/CREATE DATABASE IF NOT EXISTS `loan-pricing` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;/CREATE DATABASE IF NOT EXISTS `$VERIFY_DB` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;/; s/USE `loan-pricing`;/USE `$VERIFY_DB`;/;" sql/loan_pricing_prod_init_20260331.sql | MYSQL_PWD="$DB_PASSWORD" mysql -h "$DB_HOST" -P "$DB_PORT" -u "$DB_USER"
|
||||
```
|
||||
|
||||
Expected: 两条命令都成功返回,无 SQL 执行报错。
|
||||
|
||||
- [ ] **Step 3: 校验基础初始化数据和业务空表**
|
||||
|
||||
Run:
|
||||
|
||||
```bash
|
||||
MYSQL_PWD="$DB_PASSWORD" mysql -N -h "$DB_HOST" -P "$DB_PORT" -u "$DB_USER" "$VERIFY_DB" -e "SELECT COUNT(*) FROM sys_user; SELECT COUNT(*) FROM sys_role; SELECT COUNT(*) FROM sys_menu; SELECT COUNT(*) FROM loan_pricing_workflow; SELECT COUNT(*) FROM model_corp_output_fields; SELECT COUNT(*) FROM model_retail_output_fields;"
|
||||
```
|
||||
|
||||
Expected:
|
||||
- `sys_user`、`sys_role`、`sys_menu` 结果大于 0
|
||||
- `loan_pricing_workflow`、`model_corp_output_fields`、`model_retail_output_fields` 结果都为 `0`
|
||||
|
||||
- [ ] **Step 4: 清理临时验证库**
|
||||
|
||||
Run: `MYSQL_PWD="$DB_PASSWORD" mysql -h "$DB_HOST" -P "$DB_PORT" -u "$DB_USER" -e "DROP DATABASE IF EXISTS \`$VERIFY_DB\`;"`
|
||||
Expected: PASS,验证结束后临时库被删除。
|
||||
|
||||
- [ ] **Step 5: 编写后端实施记录**
|
||||
|
||||
在 `doc/implementation-report-2026-03-31-production-db-init-export-backend.md` 记录至少以下内容:
|
||||
|
||||
```markdown
|
||||
- 新增生产初始化总脚本 `sql/loan_pricing_prod_init_20260331.sql`
|
||||
- 基础部分直接复用 `sql/ry_20250522.sql`
|
||||
- 新增 3 张业务表结构:`loan_pricing_workflow`、`model_corp_output_fields`、`model_retail_output_fields`
|
||||
- 明确未导出任何业务数据
|
||||
- 已完成静态检查和临时库导入验证
|
||||
```
|
||||
|
||||
- [ ] **Step 6: 核对实施记录路径**
|
||||
|
||||
Run: `ls doc/implementation-report-2026-03-31-production-db-init-export-backend.md`
|
||||
Expected: 文件存在于仓库 `doc/` 目录。
|
||||
|
||||
- [ ] **Step 7: 提交本任务**
|
||||
|
||||
```bash
|
||||
git add sql/loan_pricing_prod_init_20260331.sql doc/implementation-report-2026-03-31-production-db-init-export-backend.md
|
||||
git commit -m "完成生产初始化数据库脚本验证"
|
||||
```
|
||||
@@ -0,0 +1,78 @@
|
||||
# Production DB Init Export Frontend Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED: Use superpowers:executing-plans to implement this plan in this repository. Do not use subagents. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** 明确本次生产初始化数据库导出任务无前端代码改动范围,并将该结论以可追溯文档形式沉淀,避免执行阶段误改 `ruoyi-ui`。
|
||||
|
||||
**Architecture:** 本次交付物是单文件 SQL,职责只在数据库初始化层,不涉及前端页面、接口契约、构建配置或部署产物调整。因此前端计划不做功能实现,只负责范围确认、源码复核和实施记录留档,确保“无前端改动”是被显式验证过的结论,而不是口头假设。
|
||||
|
||||
**Tech Stack:** Vue 2、RuoYi 前端工程、shell、`rg`
|
||||
|
||||
---
|
||||
|
||||
### Task 1: 确认本次任务无前端实现范围
|
||||
|
||||
**Files:**
|
||||
- Inspect: `docs/superpowers/specs/2026-03-31-production-db-init-export-design.md`
|
||||
- Inspect: `ruoyi-ui/src`
|
||||
- Inspect: `ruoyi-ui/package.json`
|
||||
|
||||
- [ ] **Step 1: 核对设计文档中的交付物边界**
|
||||
|
||||
Run: `rg -n "单一 \\.sql|生产初始化|不包含任何业务数据|业务表结构" docs/superpowers/specs/2026-03-31-production-db-init-export-design.md`
|
||||
Expected: 能看到本次交付物明确限定为数据库初始化 SQL,不包含前端实现要求。
|
||||
|
||||
- [ ] **Step 2: 检查前端目录中不存在与本次任务直接相关的待改文件**
|
||||
|
||||
Run: `rg -n "loan_pricing_prod_init|production db init|数据库导出|初始化脚本" ruoyi-ui/src ruoyi-ui/package.json`
|
||||
Expected: 无输出,说明前端工程不存在与本次 SQL 导出任务耦合的实现点。
|
||||
|
||||
- [ ] **Step 3: 明确本次执行阶段不得改动 `ruoyi-ui`**
|
||||
|
||||
把执行约束写入实施记录草稿,至少包含:
|
||||
|
||||
```markdown
|
||||
- 本次任务交付物为数据库初始化 SQL
|
||||
- 不修改 `ruoyi-ui` 下任何源码、接口或构建配置
|
||||
- 如执行中出现前端需求,应回到新需求重新做设计和计划
|
||||
```
|
||||
|
||||
- [ ] **Step 4: 提交本任务**
|
||||
|
||||
```bash
|
||||
git add docs/superpowers/plans/2026-03-31-production-db-init-export-frontend-plan.md
|
||||
git commit -m "补充生产初始化数据库导出前端计划"
|
||||
```
|
||||
|
||||
### Task 2: 补前端实施记录并留痕无改动结论
|
||||
|
||||
**Files:**
|
||||
- Create: `doc/implementation-report-2026-03-31-production-db-init-export-frontend.md`
|
||||
|
||||
- [ ] **Step 1: 编写前端实施记录**
|
||||
|
||||
实施记录至少写明:
|
||||
|
||||
```markdown
|
||||
- 已根据设计文档确认本次交付物仅为数据库初始化单文件 SQL
|
||||
- 已检查 `ruoyi-ui` 工程,不存在需要随本次任务修改的页面、接口或构建配置
|
||||
- 本次前端范围为无代码改动
|
||||
- 执行阶段应保持 `ruoyi-ui` 目录不变
|
||||
```
|
||||
|
||||
- [ ] **Step 2: 核对实施记录路径**
|
||||
|
||||
Run: `ls doc/implementation-report-2026-03-31-production-db-init-export-frontend.md`
|
||||
Expected: 文件存在于仓库 `doc/` 目录。
|
||||
|
||||
- [ ] **Step 3: 再次确认 `ruoyi-ui` 未被纳入提交范围**
|
||||
|
||||
Run: `git status --short ruoyi-ui`
|
||||
Expected: 无本次任务新增或修改的前端文件;如果有输出,需要先确认是否为历史遗留改动,不得误提交。
|
||||
|
||||
- [ ] **Step 4: 提交本任务**
|
||||
|
||||
```bash
|
||||
git add doc/implementation-report-2026-03-31-production-db-init-export-frontend.md
|
||||
git commit -m "补充生产初始化数据库导出前端实施记录"
|
||||
```
|
||||
Reference in New Issue
Block a user