Fix duplicate type errors when loading into postgresql.

This commit is contained in:
Eevee 2012-03-30 23:33:48 -07:00
parent 5338d44272
commit 987116f662

View file

@ -150,8 +150,19 @@ def load(session, tables=[], directory=None, drop_tables=False, verbose=False, s
# Drop all tables if requested # Drop all tables if requested
if drop_tables: if drop_tables:
bind = session.get_bind()
print_start('Dropping tables') print_start('Dropping tables')
for n, table in enumerate(reversed(table_objs)): for n, table in enumerate(reversed(table_objs)):
# Drop columns' types if appropriate; needed for enums in
# postgresql
for column in table.c:
try:
drop = column.type.drop
except AttributeError:
pass
else:
drop(bind=bind, checkfirst=True)
table.drop(checkfirst=True) table.drop(checkfirst=True)
print_status('%s/%s' % (n, len(table_objs))) print_status('%s/%s' % (n, len(table_objs)))
print_done() print_done()