Commits

shaib committed b241f6a

Define a warning for dropped constraints, and issue if for SqlServer.

Comments (0)

Files changed (2)

south/db/sql_server/pyodbc.py

 from datetime import date, datetime, time
+from warnings import warn
 from django.db import models
 from django.db.models import fields
 from south.db import generic
 from south.db.generic import delete_column_constraints, invalidate_table_constraints, copy_column_constraints
+from south.exceptions import ConstraintDropped
 
 class DatabaseOperations(generic.DatabaseOperations):
     """
                     #params.update(column = qn(name), target = target)
                     #sql = self.create_foreign_key_sql % params
                 elif ctype=='CHECK':
+                    warn(ConstraintDropped("CHECK "+ args, table_name, name))
                     continue
                     #TODO: Some check constraints should be restored; but not before the generic
                     #      backend restores them.

south/exceptions.py

 class SouthError(RuntimeError):
     pass
 
+class SouthWarning(RuntimeWarning):
+    pass
 
 class BrokenMigration(SouthError):
     def __init__(self, migration, exc_info):
 class ImpossibleORMUnfreeze(SouthError):
     """Raised if the ORM can't manage to unfreeze all the models in a linear fashion."""
     pass
+
+class ConstraintDropped(SouthWarning):
+    def __init__(self, constraint, table, column=None):
+        self.table = table
+        self.column = (".%s" % column) if column else ""
+        self.constraint = constraint
+    
+    def __str__(self):
+        return "Constraint %(constraint)s was dropped from %(table)s%(column)s -- was this intended?" % self.__dict__