python - 更改迁移创建的文件的名称

标签 python alembic

是否可以更改通过迁移创建的文件的名称?像这样 `18b6422c9d3f 我更喜欢像 201705121927 这样组织使用日期时间

是否可以更改 alembic 配置来做到这一点?

最佳答案

您需要编辑alembic.ini

您要查找的参数是 file_template

来自 docs :

file_template - this is the naming scheme used to generate new migration files. The value present is the default, so is commented out. Tokens available include:

  • %%(rev)s - revision id
  • %%(slug)s - a truncated string derived from the revision message
  • %%(year)d, %%(month).2d, %%(day).2d, %%(hour).2d, %%(minute).2d, %%(second).2d - components of the create date, by default datetime.datetime.now() unless the timezone configuration option is also used.

默认设置为 %%(rev)s_%%(slug)s

关于python - 更改迁移创建的文件的名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43947307/

相关文章:

python - 将 Django 部署到 Heroku(Psycopg2 错误)

python - 抓取新闻(Python 3.6,BeautifulSoup)

python - Sklearn OneClassSVM 与 RandomizedSearchCV : "ValueError: ' f' is not in list"

python - 自定义调度程序以具有带超时/终止开关的顺序 + 半顺序脚本?

python - 通过 alembic 脚本并发数据库表索引

python - 如何在 flask-migrate 迁移中自动导入模块

python - 如何为使用 gmail 发送的电子邮件添加主题?

python - 使用 Alembic 的 SqlAlchemy 创建 double 列

flask - 为什么 Flask-Migrate 让我进行两步迁移?

python - 如何在 sqlalchemy for mysql 中的另一列之后添加一列?