Fix terrible path finding code in 1679b5bc102 migration

This commit fixes a blatant bug in the 1679b5bc102. If there was a '.'
in the path of the migration file (which there will be if it's
installed, because of python 2.x or python 3.x, then the hack of path
finding code will not generate the correct path and the migration will
fail before it even began.

Change-Id: I4008b13dc356450eb463e81cff7d30230aed96eb
This commit is contained in:
Matthew Treinish
2015-03-17 14:23:55 -04:00
parent 86b867521e
commit ec7540e8f0

View File

@@ -40,7 +40,10 @@ CONF = cfg.CONF
def upgrade():
sql_path = os.path.realpath(__file__).split('.')[0] + '.mysql_upgrade.sql'
migration_file = ('1679b5bc102c_add_subsecond_columns_to_test_runs_table.'
'mysql_upgrade.sql')
migration_dir = os.path.dirname(os.path.realpath(__file__))
sql_path = os.path.join(migration_dir, migration_file)
migration_context = context.get_context()
if migration_context.dialect.name == 'mysql':
with open(sql_path, 'r') as sql_file: