chore: migrate IDE environment from Kiro to Claude Code
- Add CLAUDE.md (root + ETL subdirectory + db subdirectory) consolidating all Kiro steering docs - Add .mcp.json migrated from .kiro/settings/mcp.json (test DBs enabled, prod disabled) - Add .claude/commands/ (audit, doc-sync, db-docs) replacing Kiro skills - Add .claude/hooks/ (session_start, post_edit_audit, stop_audit_check) replacing Kiro hooks - Add .claude/settings.json registering all hooks - Add scripts/audit/prescan.py merging Kiro's audit_flagger + compliance_prescan - Remove .kiro/agents, hooks, scripts, settings, skills, state (migrated or obsolete) - Update .gitignore for Claude Code Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
45
db/CLAUDE.md
Normal file
45
db/CLAUDE.md
Normal file
@@ -0,0 +1,45 @@
|
||||
# CLAUDE.md — Database (DDL / Migrations / Seeds)
|
||||
|
||||
进入本目录时自动加载。
|
||||
|
||||
## Schema 变更规则
|
||||
|
||||
修改任何影响 PostgreSQL schema 的内容(迁移脚本/DDL/表定义)时,必须同步更新 `docs/database/`:
|
||||
|
||||
1. **变更说明**:新增/修改/删除的表、字段、约束、索引
|
||||
2. **兼容性**:对 ETL、后端 API、小程序字段映射的影响
|
||||
3. **回滚策略**:如何撤销(DDL 回滚 / 数据回填)
|
||||
4. **验证步骤**:至少 3 条校验 SQL
|
||||
|
||||
## RLS 视图双 Schema 规则
|
||||
|
||||
新建 DWS/DWD 表的 RLS 视图必须同时在原 schema(如 `dws`)和 `app` schema 创建:
|
||||
|
||||
```sql
|
||||
-- 1. 原 schema
|
||||
CREATE VIEW dws.v_xxx AS SELECT ... WHERE site_id = current_setting('app.current_site_id')::int;
|
||||
|
||||
-- 2. app schema(后端通过此路径访问)
|
||||
CREATE VIEW app.v_xxx AS SELECT ... WHERE site_id = current_setting('app.current_site_id')::int;
|
||||
```
|
||||
|
||||
回滚需逆序 DROP 两个 schema 的视图。只在原 schema 创建会导致后端查询失败。
|
||||
|
||||
## 目录结构
|
||||
|
||||
```
|
||||
db/
|
||||
├── etl_feiqiu/
|
||||
│ ├── schemas/ # 六层 Schema DDL(meta/ods/dwd/core/dws/app)
|
||||
│ ├── migrations/ # 迁移脚本(日期前缀:YYYY-MM-DD__slug.sql)
|
||||
│ ├── seeds/ # 种子数据
|
||||
│ └── scripts/ # 测试数据库脚本
|
||||
├── zqyy_app/
|
||||
│ └── schemas/ # 业务数据库 DDL
|
||||
└── fdw/ # FDW 跨库只读映射
|
||||
```
|
||||
|
||||
## 测试规范
|
||||
|
||||
- 数据库操作使用测试库(`TEST_DB_DSN` / `TEST_APP_DB_DSN`),禁止连正式库
|
||||
- 迁移脚本在测试库执行后需验证表结构
|
||||
Reference in New Issue
Block a user