From 073a2f7cdeebffdcbbd5f4e8953a00fa8ab9fce2 Mon Sep 17 00:00:00 2001 From: DevilsAutumn Date: Sat, 4 May 2024 04:24:03 +0530 Subject: [PATCH] Handled failing tests. --- django/db/backends/base/schema.py | 6 +++++- tests/test_sqlite.py | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/django/db/backends/base/schema.py b/django/db/backends/base/schema.py index c0880efe49..f8dfca50af 100644 --- a/django/db/backends/base/schema.py +++ b/django/db/backends/base/schema.py @@ -919,7 +919,11 @@ class BaseDatabaseSchemaEditor: fks_dropped = set() if ( self.connection.features.supports_foreign_keys - and self.connection.features.requires_fk_constraints_to_be_recreated + and ( + self.connection.features.requires_fk_constraints_to_be_recreated + or not old_field.related_model == new_field.related_model + or getattr(new_field, "db_constraint", True) is False + ) and old_field.remote_field and old_field.db_constraint and self._field_should_be_altered( diff --git a/tests/test_sqlite.py b/tests/test_sqlite.py index f3ccf2c021..dab6b46041 100644 --- a/tests/test_sqlite.py +++ b/tests/test_sqlite.py @@ -14,10 +14,20 @@ DATABASES = { "default": { - "ENGINE": "django.db.backends.sqlite3", + "ENGINE": "django.db.backends.postgresql", + "NAME": "django", + "USER": "postgres", + "PASSWORD": "postgres", + "HOST": "127.0.0.1", + "PORT": "5432", }, "other": { - "ENGINE": "django.db.backends.sqlite3", + "ENGINE": "django.db.backends.postgresql", + "NAME": "django", + "USER": "postgres", + "PASSWORD": "postgres", + "HOST": "127.0.0.1", + "PORT": "5432", }, }