Opened 2 years ago
Closed 2 years ago
#34895 closed Bug (duplicate)
Reverse migrations fail with mysql / mariadb with sql_safe_updates set to 1
| Reported by: | Divick | Owned by: | nobody |
|---|---|---|---|
| Component: | Migrations | Version: | 4.0 |
| Severity: | Normal | Keywords: | migrations |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
For one of the migrations when I tried deleting, it generates something like the following:
DELETE FROM `django_migrations` WHERE (`django_migrations`.`app` = 'cards' AND `django_migrations`.`name` = '0023_user_pin_code');
The problem is that django_migrations.name column is not indexed nor is django_migrations.app column, which leads to sql_safe_update error:
MySQLdb.OperationalError: (1175, 'You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column')
I think django_migrations.name column can be made unique to solve this issue.
The version of Django that I am using is 4.0.10.
Note:
See TracTickets
for help on using tickets.
Duplicate of #30490.