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

Change name of file created by migration

是否可以更改迁移创建的文件的名称?像这样`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