Created
September 5, 2017 16:01
-
-
Save bluethon/219be51d7c2bffa1ffd916509374d072 to your computer and use it in GitHub Desktop.
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
# in env.py | |
from sqlalchemy.ext.compiler import compiles | |
from alembic.ddl.base import AddColumn, alter_table, add_column | |
@compiles(AddColumn) | |
def visit_add_column(element, compiler, **kw): | |
sql = "%s %s" % ( | |
alter_table(compiler, element.table_name, element.schema), | |
add_column(compiler, element.column, **kw) | |
) | |
if 'after' in element.column.info: | |
sql += ' AFTER `%s`' % element.column.info['after'] | |
return sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment