script.py.mako 785 Bytes
Newer Older
Lukáš Lalinský's avatar
Lukáš Lalinský committed
1 2 3 4
<%!
import re

%>"""${message}
Lukáš Lalinský's avatar
Lukáš Lalinský committed
5 6 7 8 9 10

Revision ID: ${up_revision}
Revises: ${down_revision | comma,n}
Create Date: ${create_date}

"""
Lukáš Lalinský's avatar
Lukáš Lalinský committed
11 12 13
from alembic import op
import sqlalchemy as sa
${imports if imports else ""}
Lukáš Lalinský's avatar
Lukáš Lalinský committed
14 15 16 17 18 19 20 21

# revision identifiers, used by Alembic.
revision = ${repr(up_revision)}
down_revision = ${repr(down_revision)}
branch_labels = ${repr(branch_labels)}
depends_on = ${repr(depends_on)}


Lukáš Lalinský's avatar
Lukáš Lalinský committed
22 23 24 25 26 27 28 29 30 31 32
def upgrade(engine_name):
    globals()["upgrade_%s" % engine_name]()


def downgrade(engine_name):
    globals()["downgrade_%s" % engine_name]()
% for db_name in re.split(r',\s*', config.get_main_option("databases")):


def upgrade_${db_name}():
    ${context.get("%s_upgrades" % db_name, "pass")}
Lukáš Lalinský's avatar
Lukáš Lalinský committed
33 34


Lukáš Lalinský's avatar
Lukáš Lalinský committed
35 36 37
def downgrade_${db_name}():
    ${context.get("%s_downgrades" % db_name, "pass")}
% endfor