Modify

Ticket #776 (assigned defect)

Opened 2 years ago

Last modified 15 months ago

Cannot drop index that was created when the table was created.

Reported by: tapocol@… Owned by: andrew
Priority: major Milestone: 1.0
Component: databaseapi Version: 0.7.2
Keywords: Cc:

Description

To reproduce with MySQL:

  • Make a model with a field that has db_index: True
  • Generate migration with --initial
  • Run Migration
  • Remove db_index: True from field settings.
  • Generate migration with --auto
  • Run Migration to see the error.

db_create_index and db_create_table with a field that has the setting 'db_index' seem to create two different naming styles for the index. db_delete_index uses the naming style used by db_create_index. So, when it is trying to delete the index that was created in db_create_table, MySQL returns the error message "Can't DROP 'xxx_xxx'; check that column/key exists".

Attachments

Change History

comment:1 Changed 2 years ago by andrew

  • Status changed from new to assigned
  • Component changed from commands to databaseapi
  • Milestone set to 1.0

comment:2 Changed 16 months ago by Petri Lehtinen <petri@…>

This affects me too. I have a foreign key and would like to remove its index.

./manage.py shemamigration app --auto generates a call like db.delete_index('app_model', ['field_id']) which, when applied, tries to delete the index app_table_field_id. In the database, the index's actual name is app_table_hexstr, so there are two different naming styles indeed.

comment:3 Changed 15 months ago by thasonic@…

I've made the patch and created the pull request: https://bitbucket.org/andrewgodwin/south/pull-request/34/fixed-issue-776

View

Add a comment

Modify Ticket

Action
as assigned
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.