diff --git a/django/core/management.py b/django/core/management.py index c85bbcbfe4..d6da2ab865 100644 --- a/django/core/management.py +++ b/django/core/management.py @@ -290,7 +290,7 @@ def get_sql_delete(app): output.append('%s %s %s %s;' % \ (style.SQL_KEYWORD('ALTER TABLE'), style.SQL_TABLE(backend.quote_name(table)), - style.SQL_KEYWORD('DROP CONSTRAINT'), + style.SQL_KEYWORD(backend.get_drop_foreignkey_sql()), style.SQL_FIELD(backend.quote_name("%s_referencing_%s_%s" % (col, r_table, r_col))))) del references_to_delete[klass] diff --git a/django/db/backends/ado_mssql/base.py b/django/db/backends/ado_mssql/base.py index 03216982a0..b43be1fa7a 100644 --- a/django/db/backends/ado_mssql/base.py +++ b/django/db/backends/ado_mssql/base.py @@ -121,6 +121,9 @@ def get_limit_offset_sql(limit, offset=None): def get_random_function_sql(): return "RAND()" +def get_drop_foreignkey_sql(): + return "DROP CONSTRAINT" + OPERATOR_MAPPING = { 'exact': '= %s', 'iexact': 'LIKE %s', diff --git a/django/db/backends/dummy/base.py b/django/db/backends/dummy/base.py index 07648033ed..89fec00c1d 100644 --- a/django/db/backends/dummy/base.py +++ b/django/db/backends/dummy/base.py @@ -33,4 +33,5 @@ get_date_extract_sql = complain get_date_trunc_sql = complain get_limit_offset_sql = complain get_random_function_sql = complain +get_drop_foreignkey_sql = complain OPERATOR_MAPPING = {} diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py index ac2e7c7b3e..f3282553e6 100644 --- a/django/db/backends/mysql/base.py +++ b/django/db/backends/mysql/base.py @@ -146,6 +146,9 @@ def get_limit_offset_sql(limit, offset=None): def get_random_function_sql(): return "RAND()" +def get_drop_foreignkey_sql(): + return "DROP FOREIGN KEY" + OPERATOR_MAPPING = { 'exact': '= %s', 'iexact': 'LIKE %s', diff --git a/django/db/backends/postgresql/base.py b/django/db/backends/postgresql/base.py index 20800f37bf..3c807f2120 100644 --- a/django/db/backends/postgresql/base.py +++ b/django/db/backends/postgresql/base.py @@ -98,6 +98,9 @@ def get_limit_offset_sql(limit, offset=None): def get_random_function_sql(): return "RANDOM()" +def get_drop_foreignkey_sql(): + return "DROP CONSTRAINT" + # Register these custom typecasts, because Django expects dates/times to be # in Python's native (standard-library) datetime/time format, whereas psycopg # use mx.DateTime by default. diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py index efc775d0c3..ecaf9b0c0d 100644 --- a/django/db/backends/sqlite3/base.py +++ b/django/db/backends/sqlite3/base.py @@ -116,6 +116,9 @@ def get_limit_offset_sql(limit, offset=None): def get_random_function_sql(): return "RANDOM()" +def get_drop_foreignkey_sql(): + return "" + def _sqlite_date_trunc(lookup_type, dt): try: dt = util.typecast_timestamp(dt)