You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iTi-Flask/docs/SEEDS.md

57 lines
1.0 KiB
Markdown

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# 种子数据
iTi-Flask 不提供系统 seed。
seed 分三类:
- 框架 seed当前没有。
- 系统 seed`iti-system` 提供。
- 业务 seed由业务项目自己维护。
## 规则
seed 代码必须:
- 幂等。
- 可重复执行。
- 按唯一键 upsert。
- 不做破坏性操作。
seed 代码不得:
- 删除用户数据。
- 重置已有管理员密码。
- 写入与当前包无关的数据。
- 替代 migration 修改表结构。
## 系统 Seed
需要用户、角色、菜单等系统能力时,业务项目应依赖 `iti-system`
命令:
```bash
uv run python -m flask --app app.py iti-system seed system
```
`iti-system` seed 只写系统域初始数据。
引入即全量写入。
## 业务 Seed
业务项目可以自行提供 seed 命令。
业务 seed 可以写:
- 业务字典。
- 业务默认配置。
- 业务演示数据。
业务 seed 不应写:
- 框架内部数据。
- 其它服务的数据。
- ERP 外部系统数据。
运行时数据库文件不是 seed 文件,也不提交。