Files
mindfulness/server/alembic/README.md
2026-02-02 10:47:24 +08:00

41 lines
838 B
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.
# Alembic数据库迁移
## 1. 前置
-`server/` 下准备 `.env.dev`(或系统环境变量),至少包含:
- `DATABASE_URL=mysql+aiomysql://...`
> 注意:本仓库推荐使用 Python 虚拟环境venv。示例以 `server/.venv` 为准。
---
## 2. 安装依赖(一次性)
在仓库根目录:
```bash
python3 -m venv server/.venv
source server/.venv/bin/activate
pip install -r server/requirements.txt
```
---
## 3. 常用命令
`server/` 目录运行:
```bash
source .venv/bin/activate
alembic -c alembic.ini history
alembic -c alembic.ini upgrade head
```
---
## 4. 说明
- 连接串由 `alembic/env.py` 从环境变量 `DATABASE_URL`(或 `app/core/config.py`)读取。
- 初始迁移版本为:`0001_init_content_tables`(创建推荐系统最小内容表与画像表)。