0

When I run alembic revision -m '...', Alembic generates a new .py script with the default body looking like this:

from alembic import op

# revision identifiers, used by Alembic.
revision = '1ce7873ac4ced2'
down_revision = '1cea0ac4ced2'
branch_labels = None
depends_on = None


def upgrade():
    pass

def downgrade():
    pass

Is it possible for me to specify my own template for those two functions' body, upgrade and downgrade? I know that I could always write some sort of wrapper for this alembic revision command which would also substitute my desired function body for those two pass keywords, but I was wondering if there's an "alembic" way to do that.

Quentin
  • 1,090
  • 13
  • 24

1 Answers1

1

Answering my own question after a couple of days: I realized that script.py.mako file auto-generated in alembic's migration environment folder is essentially for this purpose of providing a template for migration scripts.

Quentin
  • 1,090
  • 13
  • 24