make migrate.changeset.constraint.ForeignKeyConstraint.autoname work
with SQLAlchemy 0.5 and 0.6
This commit is contained in:
parent
a3ae4baa29
commit
05e39b2c6c
@ -126,6 +126,14 @@ class ForeignKeyConstraint(ConstraintChangeset, schema.ForeignKeyConstraint):
|
||||
|
||||
def autoname(self):
|
||||
"""Mimic the database's automatic constraint names"""
|
||||
if hasattr(self.columns, 'keys'):
|
||||
# SA <= 0.5
|
||||
firstcol = self.columns[self.columns.keys()[0]]
|
||||
ret = "%(table)s_%(firstcolumn)s_fkey" % dict(
|
||||
table=firstcol.table.name,
|
||||
firstcolumn=firstcol.name,)
|
||||
else:
|
||||
# SA >= 0.6
|
||||
ret = "%(table)s_%(firstcolumn)s_fkey" % dict(
|
||||
table=self.table.name,
|
||||
firstcolumn=self.columns[0],)
|
||||
|
Loading…
x
Reference in New Issue
Block a user