Skip to content

Commit

Permalink
handle empty migration list case for wide listing
Browse files Browse the repository at this point in the history
  • Loading branch information
reedstrm committed Feb 22, 2018
1 parent 7a8e0e2 commit e981281
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions dbmigrator/commands/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,17 @@ def cli_command(cursor, migrations_directory='', db_connection_string='',
migrations = utils.get_migrations(migrations_directory,
import_modules=True)

name_width = 15

if wide:
migrations = list(migrations)
name_width = max([len(name) for _, name, _ in migrations])
else:
name_width = 15
try:
name_width = max([len(name) for _, name, _ in migrations])
except ValueError:
if migrations == []:
pass
else:
raise

name_format = '{:<%s}' % (name_width,)
print('version | {} | is applied | date applied'
Expand Down

0 comments on commit e981281

Please sign in to comment.