nova/nova/db/sqlalchemy/migrate_repo/versions/298_mysql_extra_specs_binary_collation.py
Nicolas Simonds 402b3abf99 Use utf8_bin collation on the flavor extra-specs table in MySQL
On the MySQL backend, change the collation type on flavor extra-specs
to be utf8_bin, i.e., case-sensitive.

Other backends (e.g., SQLite) are case-sensitive, and the code
around extra-spec duplicate detection assumes this is universally
true.  This author is of the opinion that treating what is essentially
user-input as case-sensitive is a good idea, so assume the code is
correct, and fix the database.

TrivialFix
Change-Id: I64f1cc1b5c604085f879a25cbbd47c04b05e096d
Closes-Bug: 1463948
2015-07-21 15:02:53 -05:00

21 lines
869 B
Python

# Copyright 2015 Cisco Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
def upgrade(migrate_engine):
if migrate_engine.name == "mysql":
migrate_engine.execute("ALTER TABLE instance_type_extra_specs "
"CONVERT TO CHARACTER SET utf8 "
"COLLATE utf8_bin;")