66 lines
1.8 KiB
Makefile
66 lines
1.8 KiB
Makefile
# DjangoAdmin FastAPI+NaiveVue 常用命令
|
||
# Windows 无 make 时可用:python -m pytest / python src/main.py 等直接执行
|
||
|
||
.PHONY: install dev test test-contract test-unit test-integration lint db-init db-migrate db-migrate-dry-run migrate-revision migrate-upgrade migrate-stamp seed-dict demo-job-loop
|
||
|
||
# 安装依赖(运行 + 开发)
|
||
install:
|
||
pip install -r requirements.txt -r requirements-dev.txt
|
||
|
||
# 启动开发服务
|
||
dev:
|
||
python src/main.py
|
||
|
||
# 全部测试(默认跳过 integration)
|
||
test:
|
||
pytest
|
||
|
||
# 契约快照测试
|
||
test-contract:
|
||
pytest tests/contract -m contract
|
||
|
||
# 单元测试
|
||
test-unit:
|
||
pytest tests/unit
|
||
|
||
# 集成测试(需真实 MySQL/Redis)
|
||
test-integration:
|
||
pytest tests/integration -m integration
|
||
|
||
# 静态检查(需 pip install ruff)
|
||
lint:
|
||
ruff check .
|
||
|
||
# 初始化数据库(建库 + SQL 导入 + 补表 + alembic stamp)
|
||
db-init:
|
||
python scripts/init_db.py
|
||
|
||
# 初始化业务字典数据(幂等,按 code 判重,已存在跳过)
|
||
seed-dict:
|
||
python scripts/seed_dict.py
|
||
|
||
# 定时任务闭环演示:调度 → 执行 → 任务日志
|
||
demo-job-loop:
|
||
python scripts/demo_job_loop.py
|
||
|
||
# 生成增量迁移(修改模型后执行,会 diff 当前库)
|
||
migrate-revision:
|
||
alembic revision --autogenerate -m "描述"
|
||
|
||
# 应用迁移
|
||
migrate-upgrade:
|
||
alembic upgrade head
|
||
|
||
# 标记当前库已到基线
|
||
migrate-stamp:
|
||
alembic stamp head
|
||
|
||
# 跨库数据迁移(MySQL→PostgreSQL/MSSQL/SQLite):连接参数用 ARGS 透传,如
|
||
# make db-migrate ARGS="--src-driver=mysql --src-db=... --dst-driver=postgresql --dst-db=..."
|
||
db-migrate:
|
||
python scripts/migrate_db.py $(ARGS)
|
||
|
||
# 跨库迁移干跑:只连源、逐表数行数、打印迁移计划,不碰目标库
|
||
db-migrate-dry-run:
|
||
python scripts/migrate_db.py --dry-run $(ARGS)
|