Merge "Fix INSTR not supported for postgresql"
This commit is contained in:
commit
85a91ba143
@ -24,6 +24,12 @@ def has_migrations(engine):
|
||||
"""
|
||||
sql_query = ("select meta_data from image_locations where "
|
||||
"INSTR(meta_data, '\"backend\":') > 0")
|
||||
|
||||
# NOTE(abhishekk): INSTR function doesn't supported in postgresql
|
||||
if engine.name == 'postgresql':
|
||||
sql_query = ("select meta_data from image_locations where "
|
||||
"POSITION('\"backend\":' IN meta_data) > 0")
|
||||
|
||||
with engine.connect() as con:
|
||||
metadata_backend = con.execute(sql_query)
|
||||
if metadata_backend.rowcount > 0:
|
||||
@ -37,6 +43,13 @@ def migrate(engine):
|
||||
sql_query = ("UPDATE image_locations SET meta_data = REPLACE(meta_data, "
|
||||
"'\"backend\":', '\"store\":') where INSTR(meta_data, "
|
||||
" '\"backend\":') > 0")
|
||||
|
||||
# NOTE(abhishekk): INSTR function doesn't supported in postgresql
|
||||
if engine.name == 'postgresql':
|
||||
sql_query = ("UPDATE image_locations SET meta_data = REPLACE("
|
||||
"meta_data, '\"backend\":', '\"store\":') where "
|
||||
"POSITION('\"backend\":' IN meta_data) > 0")
|
||||
|
||||
with engine.connect() as con:
|
||||
migrated_rows = con.execute(sql_query)
|
||||
return migrated_rows.rowcount
|
||||
|
@ -99,6 +99,11 @@ class TestTrainMigrate01MySQL(TestTrainMigrate01Mixin,
|
||||
pass
|
||||
|
||||
|
||||
class TestTrain01PostgresSQL(TestTrainMigrate01Mixin,
|
||||
test_base.PostgreSQLOpportunisticTestCase):
|
||||
pass
|
||||
|
||||
|
||||
class TestTrainMigrate01_EmptyDBMixin(test_migrations.AlembicMigrationsMixin):
|
||||
"""This mixin is used to create an initial glance database and upgrade it
|
||||
up to the train_expand01 revision.
|
||||
@ -127,5 +132,9 @@ class TestTrainMigrate01_EmptyDBMixin(test_migrations.AlembicMigrationsMixin):
|
||||
|
||||
class TestTrainMigrate01_EmptyDBMySQL(TestTrainMigrate01_EmptyDBMixin,
|
||||
test_base.MySQLOpportunisticTestCase):
|
||||
"""This test runs the Train data migrations on an empty databse."""
|
||||
pass
|
||||
|
||||
|
||||
class TestTrainMigrate01_PySQL(TestTrainMigrate01_EmptyDBMixin,
|
||||
test_base.PostgreSQLOpportunisticTestCase):
|
||||
pass
|
||||
|
Loading…
x
Reference in New Issue
Block a user