Make utf8 the default charset for mysql

Newer versions of oslo_db added a sanity check to ensure that table's
charsets are utf8. This patch makes this change explicit and re-enables
the sanity check that was disabled in Ifffbdd50c38a1d25215faa6a966c2d2a63935711

Change-Id: Icbc41bd3964a6124d3e0d906cb85944fdc312844
Closes-bug: #1411489
This commit is contained in:
Flavio Percoco 2015-05-08 11:56:28 +02:00 committed by Mike Fedosin
parent 1c8cd0e86c
commit 647d2895a7
4 changed files with 10 additions and 11 deletions

View File

@ -62,5 +62,4 @@ def db_sync(version=None, init_version=0, engine=None):
return get_backend().db_sync(engine=engine,
abs_path=MIGRATE_REPO_PATH,
version=version,
init_version=init_version,
sanity_check=False)
init_version=init_version)

View File

@ -67,7 +67,7 @@ class JSONEncodedDict(TypeDecorator):
class GlanceBase(models.ModelBase, models.TimestampMixin):
"""Base class for Glance Models."""
__table_args__ = {'mysql_engine': 'InnoDB'}
__table_args__ = {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}
__table_initialized__ = False
__protected_attributes__ = set([
"created_at", "updated_at", "deleted_at", "deleted"])

View File

@ -44,7 +44,7 @@ _LW = i18n._LW
class ArtifactBase(models.ModelBase, models.TimestampMixin):
"""Base class for Artifact Models."""
__table_args__ = {'mysql_engine': 'InnoDB'}
__table_args__ = {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}
__table_initialized__ = False
__protected_attributes__ = set([
"created_at", "updated_at"])
@ -102,7 +102,7 @@ class Artifact(BASE, ArtifactBase):
Index('ix_artifact_state', 'state'),
Index('ix_artifact_owner', 'owner'),
Index('ix_artifact_visibility', 'visibility'),
{'mysql_engine': 'InnoDB'})
{'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'})
__protected_attributes__ = ArtifactBase.__protected_attributes__.union(
set(['published_at', 'deleted_at']))
@ -219,7 +219,7 @@ class ArtifactDependency(BASE, ArtifactBase):
'artifact_dest'),
Index('ix_artifact_dependencies_direct_dependencies',
'artifact_source', 'is_direct'),
{'mysql_engine': 'InnoDB'})
{'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'})
id = Column(String(36), primary_key=True, nullable=False,
default=lambda: str(uuid.uuid4()))
@ -248,7 +248,7 @@ class ArtifactTag(BASE, ArtifactBase):
__table_args__ = (Index('ix_artifact_tags_artifact_id', 'artifact_id'),
Index('ix_artifact_tags_artifact_id_tag_value',
'artifact_id', 'value'),
{'mysql_engine': 'InnoDB'},)
{'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'},)
id = Column(String(36), primary_key=True, nullable=False,
default=lambda: str(uuid.uuid4()))
@ -265,7 +265,7 @@ class ArtifactProperty(BASE, ArtifactBase):
__table_args__ = (
Index('ix_artifact_properties_artifact_id', 'artifact_id'),
Index('ix_artifact_properties_name', 'name'),
{'mysql_engine': 'InnoDB'},)
{'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'},)
id = Column(String(36), primary_key=True, nullable=False,
default=lambda: str(uuid.uuid4()))
artifact_id = Column(String(36), ForeignKey('artifacts.id'),
@ -287,7 +287,7 @@ class ArtifactBlob(BASE, ArtifactBase):
__table_args__ = (
Index('ix_artifact_blobs_artifact_id', 'artifact_id'),
Index('ix_artifact_blobs_name', 'name'),
{'mysql_engine': 'InnoDB'},)
{'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'},)
id = Column(String(36), primary_key=True, nullable=False,
default=lambda: str(uuid.uuid4()))
artifact_id = Column(String(36), ForeignKey('artifacts.id'),
@ -306,7 +306,7 @@ class ArtifactBlobLocation(BASE, ArtifactBase):
__tablename__ = 'artifact_blob_locations'
__table_args__ = (Index('ix_artifact_blob_locations_blob_id',
'blob_id'),
{'mysql_engine': 'InnoDB'})
{'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'})
id = Column(String(36), primary_key=True, nullable=False,
default=lambda: str(uuid.uuid4()))

View File

@ -48,7 +48,7 @@ BASE_DICT = declarative_base(cls=DictionaryBase)
class GlanceMetadefBase(models.TimestampMixin):
"""Base class for Glance Metadef Models."""
__table_args__ = {'mysql_engine': 'InnoDB'}
__table_args__ = {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}
__table_initialized__ = False
__protected_attributes__ = set(["created_at", "updated_at"])