]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
encryption_id needs to be non-nullable
authorjun xie <junxiebj@cn.ibm.com>
Fri, 19 Dec 2014 16:24:22 +0000 (00:24 +0800)
committerjun xie <junxiebj@cn.ibm.com>
Fri, 19 Dec 2014 16:31:26 +0000 (00:31 +0800)
DB2 10.5 doesn't support primary key constraints over
nullable columns, so we have to make this column
non-nullable.

Change-Id: I3f6ded20cd8cf1902347f58f91c05446739b48f5
Closes-Bug: #1404303

cinder/db/sqlalchemy/migrate_repo/versions/033_add_encryption_unique_key.py

index 5075e65b844b7b32e267384c934f565d415d0c93..a37fa114b29a008cfd572a74e3eaabf0f10bb376 100644 (file)
@@ -24,7 +24,14 @@ def upgrade(migrate_engine):
 
     encryptions = Table('encryption', meta, autoload=True)
 
-    encryption_id = Column('encryption_id', String(36))
+    encryption_id_column_kwargs = {}
+    if migrate_engine.name == 'ibm_db_sa':
+        # NOTE(junxiebj): DB2 10.5 doesn't support primary key
+        # constraints over nullable columns, so we have to
+        # make the column non-nullable in the DB2 case.
+        encryption_id_column_kwargs['nullable'] = False
+    encryption_id = Column('encryption_id', String(36),
+                           **encryption_id_column_kwargs)
     encryptions.create_column(encryption_id)
 
     encryption_items = list(encryptions.select().execute())