misc/migration/3.8.5_Any.py
branchstable
changeset 5832 16a4235e031f
parent 5831 561014b6d70a
child 9460 a2a0bc984863
--- a/misc/migration/3.8.5_Any.py	Thu Jun 24 12:10:01 2010 +0200
+++ b/misc/migration/3.8.5_Any.py	Thu Jun 24 12:36:22 2010 +0200
@@ -2,10 +2,10 @@
     dbdriver  = config.sources()['system']['db-driver']
     if dbdriver != "sqlserver2005":
         return
-        
+
     introspection_sql = """\
 SELECT table_schema, table_name, column_name, is_nullable, character_maximum_length
-FROM information_schema.columns 
+FROM information_schema.columns
 WHERE data_type = 'VARCHAR' and table_name <> 'SYSDIAGRAMS'
 """
     has_index_sql = """\
@@ -14,8 +14,8 @@
        i.is_unique,
        i.is_unique_constraint
 FROM sys.indexes AS i, sys.index_columns as j, sys.columns as k
-WHERE is_hypothetical = 0 AND i.index_id <> 0 
-AND i.object_id = j.object_id 
+WHERE is_hypothetical = 0 AND i.index_id <> 0
+AND i.object_id = j.object_id
 AND i.index_id = j.index_id
 AND i.object_id = OBJECT_ID('%(table)s')
 AND k.name = '%(col)s'
@@ -25,7 +25,7 @@
     generated_statements = []
     for schema, table, column, is_nullable, length in sql(introspection_sql, ask_confirm=False):
         qualified_table = '[%s].[%s]' % (schema, table)
-        rset = sql(has_index_sql % {'table': qualified_table, 'col':column}, 
+        rset = sql(has_index_sql % {'table': qualified_table, 'col':column},
                    ask_confirm = False)
         drops = []
         creates = []
@@ -40,7 +40,7 @@
                 else:
                     unique = ''
                 creates.append('CREATE %s %s INDEX %s ON %s(%s)' % (unique, idx_type, idx_name, qualified_table, column))
-            
+
         if length == -1:
             length = 'max'
         if is_nullable == 'YES':
@@ -49,11 +49,11 @@
             not_null = 'NOT NULL'
         alter_sql = 'ALTER TABLE %s ALTER COLUMN %s NVARCHAR(%s) %s' % (qualified_table, column, length, not_null)
         generated_statements+= drops + [alter_sql] + creates
-        
-    
+
+
     for statement in generated_statements:
         print statement
         sql(statement, ask_confirm=False)
     commit()
-    
+
 migrate_varchar_to_nvarchar()