From b3019ae8ee54f75b1dd344dd776f437ee3e94fa8 Mon Sep 17 00:00:00 2001 From: Ekaterina Fedorova Date: Tue, 29 Apr 2014 16:33:14 +0400 Subject: [PATCH] Add custom String type to support collation Since sqlalchemy 0.7.9 does not support collation in init of default String type, custom type was added. Change-Id: I4fa841bf61d923fb80d1e52f881bcce6622923cb Closes-Bug: #1313535 --- .../db/migrate_repo/versions/004_add_repository_tables.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/muranoapi/db/migrate_repo/versions/004_add_repository_tables.py b/muranoapi/db/migrate_repo/versions/004_add_repository_tables.py index 9509465fe..320a43121 100644 --- a/muranoapi/db/migrate_repo/versions/004_add_repository_tables.py +++ b/muranoapi/db/migrate_repo/versions/004_add_repository_tables.py @@ -20,6 +20,12 @@ from sqlalchemy import types meta = schema.MetaData() +class StringWithCollation(types.String): + def __init__(self, length, collation=None, **kwargs): + super(StringWithCollation, self).__init__(length, **kwargs) + self.collation = collation + + def upgrade(migrate_engine): meta.bind = migrate_engine collation = 'ascii_general_ci' \ @@ -34,7 +40,7 @@ def upgrade(migrate_engine): nullable=False), schema.Column('archive', types.LargeBinary), schema.Column('fully_qualified_name', - types.String(512, collation=collation), + StringWithCollation(512, collation=collation), index=True, unique=True), schema.Column('type', types.String(20)), schema.Column('author', types.String(80)),