- changed milestone to 1.0.xx
support for overriding existing @compiles directives
Issue #2814
new
perhaps sending it in as a **kw.
from sqlalchemy.ext.compiler import compiles
from alembic.ddl.base import AddColumn
# ideally, the @compiles system would have some way of getting
# us the "existing" @compiles decorator, so this part is the
# hack
specs = AddColumn.__dict__.get('_compiler_dispatcher').specs
existing_dispatch = specs.get('mysql', specs['default']('default'))
@compiles(AddColumn, "mysql")
def add_column(element, compiler, **kw):
text = existing_dispatch(element, compiler, **kw)
if "after" in element.column.info:
text += " AFTER %s" % element.column.info['after']('after')
return text
from sqlalchemy import Column, Integer
from alembic.migration import MigrationContext
from alembic.operations import Operations
ctx = MigrationContext.configure(dialect_name="mysql", opts={"as_sql": True})
op = Operations(ctx)
op.add_column("t", Column('y', Integer))
op.add_column("t", Column('x', Integer, info={"after": "y"}))
Comments (2)
-
reporter -
reporter - changed milestone to 1.x.xx
- edited description
- Log in to comment