Skip to content

Commit

Permalink
Fix scrub_user_tables
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenklar committed Dec 7, 2018
1 parent bf72ffd commit c61cd82
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions daiquiri/query/management/commands/scrub_user_tables.py
Expand Up @@ -36,17 +36,17 @@ def handle(self, *args, **options):
table_name=table['name']
).first()

if job and job.phase != QueryJob.PHASE_ARCHIVED:
stale_tables.append((schema_name, table['name']))
if job and job.phase not in [QueryJob.PHASE_EXECUTING, QueryJob.PHASE_COMPLETED]:
stale_tables.append((schema_name, table['name'], job.phase if job else None))

if stale_tables:
print('The following database tables have no associated QueryJob:')

for stale_table in stale_tables:
print('* %s.%s' % stale_table)
print('%s.%s -> %s' % stale_table)

if options['delete']:
for schema_name, table_name in stale_tables:
for schema_name, table_name, phase in stale_tables:
adapter.drop_table(schema_name, table_name)

print('The tables have been deleted.')
Expand Down

0 comments on commit c61cd82

Please sign in to comment.