#33899: RemoveField on indexed fields crashes on SQLite 3.35.5+
----------------------------------+----------------------------------------
Reporter: cessor | Owner: fizaashraf37
Type: Bug | Status: assigned
Component: Migrations | Version: 4.1
Severity: Release blocker | Resolution:
Keywords: Migration Sqlite | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+----------------------------------------
Changes (by Mariusz Felisiak):
* keywords: Migration Sqlite Docker => Migration Sqlite
* has_patch: 1 => 0
* severity: Normal => Release blocker
* needs_tests: 1 => 0
Comment:
Thanks! It should be enough to avoid this optimization on indexes fields:
{{{#!diff
diff --git a/django/db/backends/sqlite3/schema.py
b/django/db/backends/sqlite3/schema.py
index 55fdf5fbfe..6c106ae868 100644
--- a/django/db/backends/sqlite3/schema.py
+++ b/django/db/backends/sqlite3/schema.py
@@ -408,10 +408,11 @@ class
DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
# For explicit "through" M2M fields, do nothing
elif (
self.connection.features.can_alter_table_drop_column
- # Primary keys, unique fields, and foreign keys are not
- # supported in ALTER TABLE DROP COLUMN.
+ # Primary keys, unique fields, indexed fields, and foreign
keys are
+ # not supported in ALTER TABLE DROP COLUMN.
and not field.primary_key
and not field.unique
+ and not field.db_index
and not (field.remote_field and field.db_constraint)
):
super().remove_field(model, field)
}}}
According to
[https://www.sqlite.org/lang_altertable.html#alter_table_drop_column
SQLite docs]:
> ''Possible reasons why the DROP COLUMN command can fail include':'
> ...
> * ''The column is indexed.''****
Regression in 3702819227fd0cdd9b581cd99e11d1561d51cbeb.
--
Ticket URL: <https://code.djangoproject.com/ticket/33899#comment:8>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/010701827339515c-9e6e36db-3b4e-4255-9742-452ecf393721-000000%40eu-central-1.amazonses.com.