Files
danyang-match/docs/database/MIGRATION_GUIDE.md
T

46 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 数据库迁移文件
## 迁移命名规范
```
V{版本号}__{描述}.sql
```
示例:
- `V001__init_base_tables.sql` — 初始化基础表
- `V002__add_profiles.sql` — 添加资料表
- `V003__add_review_tables.sql` — 添加审核表
- `V004__add_match_tables.sql` — 添加匹配表
- `V005__add_relationship_tables.sql` — 添加关系表
- `V006__add_messaging_tables.sql` — 添加聊天表
- `V007__add_activity_tables.sql` — 添加活动表
- `V008__add_matchmaker_tables.sql` — 添加红娘表
- `V009__add_risk_tables.sql` — 添加风控表
- `V010__add_notification_tables.sql` — 添加通知表
- `V011__add_analytics_tables.sql` — 添加统计表
## 当前迁移
### V001__init_base_tables.sql(已完成)
- users 表
- organizations 表
- operators 表
- roles 表
- permissions 表
- role_permissions 表
- operator_roles 表
- audit_logs 表
- sensitive_access_logs 表
- system_configs 表
- interest_dictionary 表
- match_rule_configs 表(需 V002 补充)
- 初始化数据(角色、权限、兴趣字典、系统配置)
## 注意事项
1. 所有迁移文件必须幂等(用 IF NOT EXISTS)
2. 敏感字段存储加密值
3. 索引命名规范:`idx_{table}_{columns}`
4. 唯一约束命名规范:`uk_{table}_{columns}`
5. 外键约束命名规范:`fk_{table}_{column}`