Compare commits

...
2 Commits
Author SHA1 Message Date
man.zhong 81727978f1 Merge branch 'main' of http://afe.git:3000/AFE_SZ_DEV/agent-skills 2026-03-17 17:20:34 +08:00
man.zhong 1a0aecbd7e chore(g3fo-db-ops): add Windows + double-confirm rules
Made-with: Cursor
2026-03-17 17:20:24 +08:00
+35
View File
@@ -97,6 +97,30 @@ python scripts/db_ops.py set_table_comment m_system_code "系统编码表"
**在 Cursor 中调用时**:使用 `run_terminal_cmd` 或 Shell 工具执行上述命令,工作目录为 `d:\AFE Git\G3SF\G3FO\server`,脚本路径为 `.claude/skills/g3fo-db-ops/scripts/db_ops.py`。 **在 Cursor 中调用时**:使用 `run_terminal_cmd` 或 Shell 工具执行上述命令,工作目录为 `d:\AFE Git\G3SF\G3FO\server`,脚本路径为 `.claude/skills/g3fo-db-ops/scripts/db_ops.py`。
## Windows 执行规范(必读)
### Python 命令优先级(Windows)
- **优先使用**:`py`
- **备选使用**:`python`
- **要求**:在 Windows 上执行本 skill 的所有命令时,先尝试 `py`,失败再尝试 `python`(不要反过来)。
### 控制台编码(避免 UnicodeEncodeError)
在 Windows/PowerShell 中执行 `db_ops.py` 时,如果输出包含中文,可能因控制台默认 GBK 编码导致 `UnicodeEncodeError`。执行前请统一设置:
```bash
# PowerShell
$env:PYTHONIOENCODING='utf-8'; py .claude/skills/g3fo-db-ops/scripts/db_ops.py test_connection
```
## 变更执行流程(双确认,强制)
1. **生成 SQL 文件**(按版本目录与序号规则落盘)
2. **展示 SQL 内容并等待用户确认**(用户确认 `yes` 后才允许执行)
3. **执行 SQL**(`batch_execute --file` / `execute`),确认返回 `"success": true`
4. **再次询问用户是否提交 Git**(用户确认后才允许 `git pull/add/commit/push`)
## Core Principles ## Core Principles
1. **Use existing templates**: Prioritize templates and tools in `g3fo-db/common_sql/` 1. **Use existing templates**: Prioritize templates and tools in `g3fo-db/common_sql/`
@@ -330,6 +354,17 @@ Reference `references/table_change_template.sql` method:
- Use `IF EXISTS` for idempotency checks - Use `IF EXISTS` for idempotency checks
- Delete procedure after execution - Delete procedure after execution
#### 列新增/DDL(强制使用存储过程模板)
所有涉及 `ALTER TABLE` 的结构变更(新增列/修改列/删除列等),一律按 `references/table_change_template.sql` 的模式执行:
- `USE <schema>;`
- `DROP PROCEDURE IF EXISTS <ProcName>;`
- `CREATE PROCEDURE <ProcName>() BEGIN ... END;`
- 在过程内通过 `information_schema.columns` 做存在性判断后再执行 `ALTER TABLE`
- `CALL <ProcName>();`
- `DROP PROCEDURE IF EXISTS <ProcName>;`
### Order Table Field Synchronization Rule ### Order Table Field Synchronization Rule
**Important: When `m_order` table adds a field, must simultaneously add same field to:** **Important: When `m_order` table adds a field, must simultaneously add same field to:**