diff --git a/neutron/db/migration/alembic_migrations/versions/2025.2/expand/d553edeb540f_tag_case_sensitive.py b/neutron/db/migration/alembic_migrations/versions/2025.2/expand/d553edeb540f_tag_case_sensitive.py index efd31611aae..e26c1424264 100644 --- a/neutron/db/migration/alembic_migrations/versions/2025.2/expand/d553edeb540f_tag_case_sensitive.py +++ b/neutron/db/migration/alembic_migrations/versions/2025.2/expand/d553edeb540f_tag_case_sensitive.py @@ -14,9 +14,15 @@ # from alembic import op +from oslo_log import log as logging +from sqlalchemy import exc -# Make "tag" resources case sensitive, using collate "utf8mb4_0900_as_cs" +LOG = logging.getLogger(__name__) + + +# Make "tag" resources case sensitive, using collate/charset +# "utf8mb4_bin/utf8mb4" # # Revision ID: d553edeb540f # Revises: ad80a9f07c5c @@ -28,7 +34,14 @@ down_revision = 'ad80a9f07c5c' def upgrade(): - op.execute('ALTER TABLE tags CONVERT TO CHARACTER SET utf8mb4 ' - 'COLLATE utf8mb4_0900_as_cs') - op.execute('ALTER TABLE tags CHARACTER SET utf8mb4 ' - 'COLLATE utf8mb4_0900_as_cs') + try: + op.execute('ALTER TABLE tags CONVERT TO CHARACTER SET utf8mb4 ' + 'COLLATE utf8mb4_bin') + op.execute('ALTER TABLE tags CHARACTER SET utf8mb4 ' + 'COLLATE utf8mb4_bin') + except exc.OperationalError as _exc: + if 'Unknown collation' in str(_exc): + LOG.error('Collation "utf8mb4_bin" does not exist; the Neutron ' + '"tag" table will remain case insensitive.') + else: + raise _exc diff --git a/releasenotes/notes/tag-case-sensitive-f94700cd349a65a2.yaml b/releasenotes/notes/tag-case-sensitive-f94700cd349a65a2.yaml index 36653241d2e..e1b7af29886 100644 --- a/releasenotes/notes/tag-case-sensitive-f94700cd349a65a2.yaml +++ b/releasenotes/notes/tag-case-sensitive-f94700cd349a65a2.yaml @@ -3,4 +3,6 @@ features: - | The resource tags are now case sensitive, following the `OpenStack guidelines `_ - for tags. + for tags. "tag" table is now using case sensitive collate/charset + ``utf8mb4_bin``/``utf8mb4``, that are present in all MariaDB releases and + since MySQL 5.5.3 (2010).