[schema migration] don't try to drop column if backend doesn't support column alteration (eg sqlite) stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 21 Jun 2010 08:53:13 +0200
branchstable
changeset 5803 589e2e3fb997
parent 5802 159b6a712d9d
child 5804 29c67578c918
[schema migration] don't try to drop column if backend doesn't support column alteration (eg sqlite)
hooks/syncschema.py
--- a/hooks/syncschema.py	Mon Jun 21 08:52:13 2010 +0200
+++ b/hooks/syncschema.py	Mon Jun 21 08:53:13 2010 +0200
@@ -21,8 +21,8 @@
 - perform physical update on the source when necessary
 
 checking for schema consistency is done in hooks.py
+"""
 
-"""
 __docformat__ = "restructuredtext en"
 
 from copy import copy
@@ -283,9 +283,10 @@
                 sqlexec('INSERT INTO %s_relation SELECT %s, %s FROM %s WHERE NOT %s IS NULL'
                         % (rtype, eidcolumn, column, table, column))
             # drop existant columns
-            for etype in rschema.subjects():
-                DropColumn(session, table=SQL_PREFIX + str(etype),
-                             column=SQL_PREFIX + rtype)
+            if session.repo.system_source.dbhelper.alter_column_support:
+                for etype in rschema.subjects():
+                    DropColumn(session, table=SQL_PREFIX + str(etype),
+                               column=SQL_PREFIX + rtype)
         else:
             for etype in rschema.subjects():
                 try:
@@ -1011,8 +1012,9 @@
             if rset[0][0] == 0 and not subjschema.eid in pendings:
                 ptypes = session.transaction_data.setdefault('pendingrtypes', set())
                 ptypes.add(rschema.type)
-                DropColumn(session, table=SQL_PREFIX + subjschema.type,
-                           column=SQL_PREFIX + rschema.type)
+                if session.repo.system_source.dbhelper.alter_column_support:
+                    DropColumn(session, table=SQL_PREFIX + subjschema.type,
+                               column=SQL_PREFIX + rschema.type)
         elif lastrel:
             DropRelationTable(session, rschema.type)
         # if this is the last instance, drop associated relation type