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.
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.
# 种子数据
框架 seed 用于初始化系统域数据。
seed 使用 Python 代码。
通过 SQLAlchemy model 和 service 适配不同数据库。
## 规则
seed 代码必须:
- 幂等。
- 只写系统域初始数据。
- 可重复执行。
- 不做破坏性操作。
seed 代码不得:
- 删除用户数据。
- 重置已有管理员密码。
- 写入业务表数据。
允许:
- 创建缺失的内置角色:`ADMIN`、`COMMON`。
- 创建缺失的内置菜单。
- 创建缺失的内置字典。
- 创建缺失的内置配置。
- 在没有管理员时创建默认管理员。
- 更新内置菜单名称、排序和权限码。
- 为 `ADMIN` 绑定全部系统菜单。
- 为 `admin` 绑定 `ADMIN` 角色。
- 写入模块通过 `ModuleMenuSeed` 声明的菜单。
- 默认为 `ADMIN` 绑定模块菜单。
不写入:
- ERP 数据。
- 业务字典。
- 业务默认账号。
- 业务表初始数据。
默认管理员:
```text
username: admin
password: 123456
role: ADMIN
```
如果 `admin` 已存在, seed 不会重置密码。
## 命令
```bash
flask iti seed system
```
预期输出:
```text
roles: created 2, updated 1, skipped 0
menus: created 18, updated 4, skipped 0
users: created 1, updated 0, skipped 1
```
运行时数据库文件不是 seed 文件,也不提交。