Commit cf2d9248 authored by Fiza Ashraf's avatar Fiza Ashraf
Browse files

[4.1.x] Fixed #33899 -- Fixed migration crash when removing indexed field on SQLite 3.35.5+.

parent 115de859ef15
......@@ -320,6 +320,7 @@ answer newbie questions, and generally made Django that much better:
Filip Noetzel <http://filip.noetzel.co.uk/>
Filip Wasilewski <filip.wasilewski@gmail.com>
Finn Gruwier Larsen <finn@gruwier.dk>
Fiza Ashraf <fizaashraf37@gmail.com>
Flávio Juvenal da Silva Junior <flavio@vinta.com.br>
flavio.curella@gmail.com
Florian Apolloner <florian@apolloner.eu>
......
......@@ -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)
......
......@@ -26,3 +26,6 @@ Bugfixes
* Fixed a regression in Django 4.1 that caused a crash of
:class:`~django.db.models.expressions.Window` expressions with
:class:`~django.contrib.postgres.aggregates.ArrayAgg` (:ticket:`33898`).
* Fixed a regression in Django 4.1 that caused a migration crash on SQLite
3.35.5+ when removing an indexed field (:ticket:`33899`).
......@@ -810,6 +810,17 @@ class SchemaTests(TransactionTestCase):
False,
)
def test_remove_indexed_field(self):
with connection.schema_editor() as editor:
editor.create_model(AuthorCharFieldWithIndex)
with connection.schema_editor() as editor:
editor.remove_field(
AuthorCharFieldWithIndex,
AuthorCharFieldWithIndex._meta.get_field("char_field"),
)
columns = self.column_classes(AuthorCharFieldWithIndex)
self.assertNotIn("char_field", columns)
def test_alter(self):
"""
Tests simple altering of fields
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment