1. Andrew Godwin
  2. south


Shai Berger  committed b241f6a

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

  • Participants
  • Parent commits 8139c07
  • Branches default

Comments (0)

Files changed (2)

File south/db/sql_server/pyodbc.py

View file
  • Ignore whitespace
 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))
                     #TODO: Some check constraints should be restored; but not before the generic
                     #      backend restores them.

File south/exceptions.py

View file
  • Ignore whitespace
 class SouthError(RuntimeError):
+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."""
+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__