Support MariaDB in the migration scripts

When using mysql+pymysql in the connection uri, the server_version_info
tupple is (5, 5, 5, 10, 1, 18, u'MariaDB'), which makes the version check
incorrectly prevent using FULLTEXT index.

Using the last four elements from the tupple seems good enough to
mitigate this inconsistency.

Change-Id: I5db3b611535e197699ea5d331f7bd073a39a31c4
This commit is contained in:
Tristan Cacqueray 2017-01-31 05:22:14 +00:00
parent 0022dbd437
commit 68df79f5ea
2 changed files with 12 additions and 0 deletions

View File

@ -33,6 +33,9 @@ LOG = log.getLogger(__name__)
def upgrade(active_plugins=None, options=None):
version_info = op.get_bind().engine.dialect.server_version_info
if version_info[-1] == "MariaDB":
# Removes fake mysql prefix
version_info = version_info[-4:]
if version_info[0] < 5 or version_info[0] == 5 and version_info[1] < 6:
LOG.warning(
"MySQL version is lower than 5.6. Skipping full-text indexes")
@ -60,6 +63,9 @@ def upgrade(active_plugins=None, options=None):
def downgrade(active_plugins=None, options=None):
version_info = op.get_bind().engine.dialect.server_version_info
if version_info[-1] == "MariaDB":
# Removes fake mysql prefix
version_info = version_info[-4:]
if version_info[0] < 5 or version_info[0] == 5 and version_info[1] < 6:
LOG.warning(
"MySQL version is lower than 5.6. Skipping full-text indexes")

View File

@ -36,6 +36,9 @@ def upgrade(active_plugins=None, options=None):
# Handle the FT Index on the user table.
version_info = op.get_bind().engine.dialect.server_version_info
if version_info[-1] == "MariaDB":
# Removes fake mysql prefix
version_info = version_info[-4:]
if version_info[0] < 5 or version_info[0] == 5 and version_info[1] < 6:
LOG.warning(
"MySQL version is lower than 5.6. Skipping full-text indexes")
@ -54,6 +57,9 @@ def downgrade(active_plugins=None, options=None):
)
version_info = op.get_bind().engine.dialect.server_version_info
if version_info[-1] == "MariaDB":
# Removes fake mysql prefix
version_info = version_info[-4:]
if version_info[0] < 5 or version_info[0] == 5 and version_info[1] < 6:
LOG.warning(
"MySQL version is lower than 5.6. Skipping full-text indexes")