Files
flaskProject/flask 数据库操作.md
YanLongChangAn ade1b6c9b0 feat(project): 初始化项目结构和配置
- 添加.gitignore和.flaskenv环境配置文件
- 创建Flask应用基础架构,包括models、services、utils模块
- 配置数据库模型User和Setting,集成SQLAlchemy和Alembic迁移
- 添加前端Vue项目结构,包含Element Plus组件库
- 配置前后端API路由和蓝prints模块
- 实现书籍下载服务BookService功能模块
- 添加代码规范配置.editorconfig、.oxfmtrc.json、.oxlintrc.json
- 配置VSCode推荐插件和前端构建工具链
- 实现文件服务FileService和相关业务逻辑
2026-04-19 15:43:45 +08:00

97 lines
1.2 KiB
Markdown
Raw Permalink 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.
# 初始化迁移仓库(只需执行一次)
```shell
flask db init
```
# 自定义模板
```shell
flask db init --template mytemplate
```
# 根据模型生成迁移脚本
```shell
flask db migrate -m "创建 User 表"
```
# 执行迁移,创建数据库表
```shell
flask db upgrade
```
# 升级到指定版本
```shell
flask db upgrade +2 # 向前2个版本
flask db upgrade ae10 # 升级到特定版本号
```
# 降级
```shell
flask db downgrade -1 # 回退1个版本
flask db downgrade base # 回退到初始状态
````
# 空迁移(手动编写SQL
```shell
flask db revision -m "手动修改"
```
# 离线生成 SQL
```shell
flask db upgrade --sql > migration.sql
```
# 合并多个迁移文件
```shell
flask db merge -m "合并分支" revision1 revision2
```
# 标记数据库为已升级到指定版本(不执行迁移)
```shell
flask db stamp revision_hash
```
# 查看迁移历史
```shell
flask db history
```
# 查看当前版本
```shell
flask db current
```
# 显示可用命令
```shell
flask db --help
```
# 查看当前分支/head
```shell
flask db heads
```
# 查看所有分支点
```shell
flask db branches
```
# 显示特定版本
```shell
flask db show <revision>
```