Explorar o código

Let syncdb work against mysql

The migration scripts are catching DatabaseError (when a table already exists,
or when we delete a table that's not there to begin with). Unfortunately, the
exception type is mysql's OperationError when we run against mysql. So we'll
just catch the more generic Exception.
bc Wong %!s(int64=14) %!d(string=hai) anos
pai
achega
941db61e21

+ 2 - 3
apps/jobsub/src/jobsub/migrations/0002_auto__add_ooziestreamingaction__add_oozieaction__add_oozieworkflow__ad.py

@@ -21,7 +21,6 @@ import logging
 from south.db import db
 from south.v2 import SchemaMigration
 from django.db import models
-from django.db.utils import DatabaseError
 
 from desktop.lib.django_db_util import remove_content_type
 from jobsub.models import JobDesign, OozieJavaAction, OozieStreamingAction, OozieDesign
@@ -101,13 +100,13 @@ class Migration(SchemaMigration):
         try:
             db.delete_table('jobsub_submission')
             remove_content_type('jobsub', 'submission')
-        except DatabaseError, ex:
+        except Exception, ex:
             pass    # Table doesn't exist. Ok.
 
         try:
             db.delete_table('jobsub_serversubmissionstate')
             remove_content_type('jobsub', 'serversubmissionstate')
-        except DatabaseError, ex:
+        except Exception, ex:
             pass    # Table doesn't exist. Ok.
 
         hue1_to_hue2_data_migration()

+ 4 - 5
apps/useradmin/src/useradmin/migrations/0001_permissions_and_profiles.py

@@ -3,7 +3,6 @@ import datetime
 from south.db import db
 from south.v2 import DataMigration
 from django.db import models
-from django.db.utils import DatabaseError
 
 from useradmin.models import UserProfile
 
@@ -19,7 +18,7 @@ class Migration(DataMigration):
           # Cloudera Enterprise
           db.delete_table('userman_groupadministrator')
           db.delete_table('userman_grouprelations')
-        except DatabaseError:
+        except Exception:
          pass
         
         try:
@@ -37,7 +36,7 @@ class Migration(DataMigration):
             elif up.creation_method == '0':
               up.creation_method = UserProfile.CreationMethod.HUE
             up.save()
-        except DatabaseError:
+        except Exception:
           # Adding model 'UserProfile'
           db.create_table('useradmin_userprofile', (
               ('home_directory', self.gf('django.db.models.fields.CharField')(max_length=1024, null=True)),
@@ -51,7 +50,7 @@ class Migration(DataMigration):
           db.rename_column('useradmin_grouppermission', 'desktop_permission_id', 'hue_permission_id')
           db.create_index('useradmin_grouppermission', ['group_id'])
           db.create_index('useradmin_grouppermission', ['hue_permission_id'])
-        except DatabaseError:
+        except Exception:
           # Adding model 'GroupPermission'
           db.create_table('useradmin_grouppermission', (
               ('hue_permission', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['useradmin.HuePermission'])),
@@ -62,7 +61,7 @@ class Migration(DataMigration):
 
         try:
           db.rename_table('userman_desktoppermission', 'useradmin_huepermission')
-        except DatabaseError:
+        except Exception:
           # Adding model 'HuePermission'
           db.create_table('useradmin_huepermission', (
               ('action', self.gf('django.db.models.fields.CharField')(max_length=100)),

+ 2 - 3
apps/useradmin/src/useradmin/migrations/0002_add_ldap_support.py

@@ -3,7 +3,6 @@ import datetime
 from south.db import db
 from south.v2 import DataMigration
 from django.db import models
-from django.db.utils import DatabaseError
 
 from django.contrib.auth.models import User
 from useradmin.models import create_profile_for_user
@@ -19,7 +18,7 @@ class Migration(DataMigration):
         try:
           db.rename_table('userman_ldapgroup', 'useradmin_ldapgroup')
           db.delete_column('useradmin_ldapgroup', 'hidden')
-        except DatabaseError, e:
+        except Exception, e:
           # Adding model 'LdapGroup'
           db.create_table('useradmin_ldapgroup', (
               ('group', self.gf('django.db.models.fields.related.ForeignKey')(related_name='group', to=orm['auth.Group'])),
@@ -30,7 +29,7 @@ class Migration(DataMigration):
         # Adding field 'UserProfile.creation_method'
         try:
           db.add_column('useradmin_userprofile', 'creation_method', self.gf('django.db.models.fields.CharField')(max_length=64, default=str(UserProfile.CreationMethod.HUE)), keep_default=False)
-        except DatabaseError:
+        except Exception:
           # It's possible that we could run into an error here, because this
           # table may have been migrated from Cloudera Enterprise, in which case
           # this column would already exist.