Adding a command of verification before upgrading or downgrading #1513
-
Suppose that in one of the stages of the DB upgrade I would like to run a command that checks if I really want to run that stage. For example, before I add a column I want to check if it was added manually exactly as I expected and then there is no need for the current step and it can be skipped. This is how I will have, for example, a certain stage: """create account table
Revision ID: 1975ea83b712
Revises:
Create Date: 2011-11-08 11:40:27.089406
"""
# revision identifiers, used by Alembic.
revision = '1975ea83b712'
down_revision = None
branch_labels = None
from alembic import op
import sqlalchemy as sa
def verification_before_upgrade():
pass
def upgrade():
pass
def verification_before_downgrade():
pass
def downgrade():
pass |
Beta Was this translation helpful? Give feedback.
Answered by
zzzeek
Jul 30, 2024
Replies: 1 comment 1 reply
-
sounds good, alembic supports that, add it to your
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
nevcohen
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sounds good, alembic supports that, add it to your
script.py.mako
template and your migration files will be generated with that format. you can break upgrade into two separate calls like this