Search code examples
pythonalembic

Change name of file created by migration


Its possible to change a name o file create by migration? like this `18b6422c9d3f i prefer organize usign date-time like 201705121927

its possible change configs of alembic to do that?


Solution

  • You need to edit alembic.ini.

    Parameter that you looking for is file_template.

    From 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.

    By default it is set to %%(rev)s_%%(slug)s.