Created
March 28, 2021 23:18
-
-
Save mtreacy002/a8c39d876572695f82dc4174267ef887 to your computer and use it in GitHub Desktop.
scrip.py.mako for flask-migrate with BIT multiple schema scenario
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""${message} | |
Revision ID: ${up_revision} | |
Revises: ${down_revision | comma,n} | |
Create Date: ${create_date} | |
""" | |
from alembic import op | |
import sqlalchemy as sa | |
${imports if imports else ""} | |
# revision identifiers, used by Alembic. | |
revision = ${repr(up_revision)} | |
down_revision = ${repr(down_revision)} | |
branch_labels = ${repr(branch_labels)} | |
depends_on = ${repr(depends_on)} | |
def upgrade(schema_name): | |
globals()["upgrade_%s" % schema_name]() | |
def downgrade(schema_name): | |
globals()["downgrade_%s" % schema_name]() | |
<% | |
import re | |
schema_names = re.split(r',\s*', "public,bitschema") | |
%> | |
% for schema_name in schema_names: | |
def upgrade_${schema_name}(): | |
${context.get("%s_upgrades" % schema_name, "pass")} | |
def downgrade_${schema_name}(): | |
${context.get("%s_downgrades" % schema_name, "pass")} | |
% endfor |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment