]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fix heal_script for MySQL specifics
authorAnn Kamyshnikova <akamyshnikova@mirantis.com>
Tue, 26 Aug 2014 08:24:20 +0000 (12:24 +0400)
committerAnn Kamyshnikova <akamyshnikova@mirantis.com>
Tue, 26 Aug 2014 09:43:27 +0000 (13:43 +0400)
After running upgrade head->downgrade havana->upgrade head
on MySQL heal_script fails with several mistakes.

This change fix them. More details in related bug description.

Closes-bug: #1354218

Change-Id: I91cb21c4bc744f240bfb8bc6b2ed24b6e01f6095

neutron/db/migration/alembic_migrations/heal_script.py

index dacb87474203bc1e310e2a3b361eb421dbffaac8..cdc5308d50b21d9f920f59673771435b171b4f18 100644 (file)
@@ -103,12 +103,12 @@ def parse_modify_command(command):
     #              autoincrement=None, existing_type=None,
     #              existing_server_default=False, existing_nullable=None,
     #              existing_autoincrement=None, schema=None, **kw)
+    bind = op.get_bind()
     for modified, schema, table, column, existing, old, new in command:
         if modified.endswith('type'):
             modified = 'type_'
         elif modified.endswith('nullable'):
             modified = 'nullable'
-            bind = op.get_bind()
             insp = sqlalchemy.engine.reflection.Inspector.from_engine(bind)
             if column in insp.get_primary_keys(table) and new:
                 return
@@ -122,8 +122,7 @@ def parse_modify_command(command):
             if isinstance(default.arg, basestring):
                 existing['existing_server_default'] = default.arg
             else:
-                existing['existing_server_default'] = default.arg.compile(
-                    dialect=bind.engine.name)
+                existing['existing_server_default'] = default.arg.text
         kwargs.update(existing)
         op.alter_column(table, column, **kwargs)