Merge pull request #1382 from alphagov/migration-fix

remove trailing underscore, which is sometimes created by alembic
This commit is contained in:
Leo Hemsted
2017-11-14 15:59:43 +00:00
committed by GitHub

View File

@@ -8,7 +8,8 @@ def get_latest_db_migration_to_apply():
project_dir = dirname(dirname(abspath(__file__))) # Get the main project directory
migrations_dir = '{}/migrations/versions/'.format(project_dir)
migration_files = [migration_file for migration_file in os.listdir(migrations_dir) if migration_file.endswith('py')]
latest_file = sorted(migration_files, reverse=True)[0].replace('.py', '')
# sometimes there's a trailing underscore, if script was created with `python app.py db migrate --rev-id=...`
latest_file = sorted(migration_files, reverse=True)[0].replace('_.py', '').replace('.py', '')
return latest_file