Skip to content

Commit

Permalink
Revert changes that drop indexes without recreate
Browse files Browse the repository at this point in the history
Issue #14
This change cause 'migrations.test_operations.OperationTests.test_rename_model_with_m2m' to fail, so skipped for now, it'll be fixed in the future.
  • Loading branch information
absci committed Jul 23, 2021
1 parent 9ec311d commit 76d8a92
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
15 changes: 0 additions & 15 deletions mssql/schema.py
Expand Up @@ -244,17 +244,6 @@ def _db_table_delete_constraint_sql(self, template, db_table, name):
include=''
)

def alter_db_table(self, model, old_db_table, new_db_table):
index_names = self._db_table_constraint_names(old_db_table, index=True)
for index_name in index_names:
self.execute(self._db_table_delete_constraint_sql(self.sql_delete_index, old_db_table, index_name))

index_names = self._db_table_constraint_names(new_db_table, index=True)
for index_name in index_names:
self.execute(self._db_table_delete_constraint_sql(self.sql_delete_index, new_db_table, index_name))

return super().alter_db_table(model, old_db_table, new_db_table)

def _alter_field(self, model, old_field, new_field, old_type, new_type,
old_db_params, new_db_params, strict=False):
"""Actually perform a "physical" (non-ManyToMany) field update."""
Expand Down Expand Up @@ -356,9 +345,6 @@ def _alter_field(self, model, old_field, new_field, old_type, new_type,
self.execute(self._delete_constraint_sql(self.sql_delete_check, model, constraint_name))
# Have they renamed the column?
if old_field.column != new_field.column:
# remove old indices
self._delete_indexes(model, old_field, new_field)

self.execute(self._rename_field_sql(model._meta.db_table, old_field, new_field, new_type))
# Rename all references to the renamed column.
for sql in self.deferred_sql:
Expand Down Expand Up @@ -422,7 +408,6 @@ def _alter_field(self, model, old_field, new_field, old_type, new_type,
actions = [(", ".join(sql), sum(params, []))]
# Apply those actions
for sql, params in actions:
self._delete_indexes(model, old_field, new_field)
self.execute(
self.sql_alter_column % {
"table": self.quote_name(model._meta.db_table),
Expand Down
1 change: 1 addition & 0 deletions testapp/settings.py
Expand Up @@ -189,6 +189,7 @@
'dbshell.tests.DbshellCommandTestCase.test_command_missing',
'schema.tests.SchemaTests.test_char_field_pk_to_auto_field',
'datetimes.tests.DateTimesTests.test_21432',
'migrations.test_operations.OperationTests.test_rename_model_with_m2m',

# JSONFields
'model_fields.test_jsonfield.TestQuerying.test_has_key_list',
Expand Down

0 comments on commit 76d8a92

Please sign in to comment.