mirror of
https://github.com/veekun/pokedex.git
synced 2024-08-20 18:16:34 +00:00
Fix duplicate type errors when loading into postgresql.
This commit is contained in:
parent
5338d44272
commit
987116f662
1 changed files with 11 additions and 0 deletions
|
@ -150,8 +150,19 @@ def load(session, tables=[], directory=None, drop_tables=False, verbose=False, s
|
|||
|
||||
# Drop all tables if requested
|
||||
if drop_tables:
|
||||
bind = session.get_bind()
|
||||
print_start('Dropping tables')
|
||||
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)
|
||||
print_status('%s/%s' % (n, len(table_objs)))
|
||||
print_done()
|
||||
|
|
Loading…
Reference in a new issue