diff --git a/django_db_constraints/autodetector.py b/django_db_constraints/autodetector.py index a21d409..3628de1 100644 --- a/django_db_constraints/autodetector.py +++ b/django_db_constraints/autodetector.py @@ -1,9 +1,9 @@ from django.db.migrations import operations from django.db.migrations.autodetector import MigrationAutodetector +from builtins import super from .operations import AlterConstraints - class MigrationAutodetectorWithDbConstraints(MigrationAutodetector): db_constraints_operations = [] diff --git a/django_db_constraints/operations.py b/django_db_constraints/operations.py index 933cef1..d137c98 100644 --- a/django_db_constraints/operations.py +++ b/django_db_constraints/operations.py @@ -1,3 +1,4 @@ +from builtins import super from django.db.migrations.operations.models import ModelOptionOperation @@ -24,8 +25,8 @@ def database_forwards(self, app_label, schema_editor, from_state, to_state): if self.allow_migrate_model(schema_editor.connection.alias, to_model): from_model = from_state.apps.get_model(app_label, self.name) - to_constraints = getattr(to_model._meta, self.option_name, {}).keys() - from_constraints = getattr(from_model._meta, self.option_name, {}).keys() + to_constraints = set(getattr(to_model._meta, self.option_name, {}).keys()) + from_constraints = set(getattr(from_model._meta, self.option_name, {}).keys()) table_operations = tuple( 'DROP CONSTRAINT IF EXISTS {name}'.format( diff --git a/setup.py b/setup.py index ff3bfb8..5fb3b28 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ def readme(): setup( name='django-db-constraints', - version='0.3.0', + version='0.3.0a', author='shangxiao', description='Add database table-level constraints to your Django model\'s Meta', long_description=readme(),