-
-
Notifications
You must be signed in to change notification settings - Fork 622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Django warnings about index_together with new migration #862
base: master
Are you sure you want to change the base?
Conversation
something to check, whether index renaming is cheap or not in the major SQL vendors (locking etc) |
also whether the index renaming is actually safe? we want to make sure that deployments including this don't cause downtime. I'm also partial to outright not having the rename by hardcoding the existing index name |
Right, let's look at the details of what this migration does. For this I'm using a local sqlite3 database for testing.
This confirms your hunch, it does delete the old index and re-create it. This could have a performance penalty. I believe this is called out by the Django docs
And this case is sqlite3. For other databases like postgres, I believe it should use the rename SQL. Also, the checks and the docs are telling me that this would have to be Django 4.1 or higher, which is a problematic requirement for migrations. Also, the "test" app has unmigrated changes when testing with Django 4.2. Those don't seem to have anything to do with the index changes in Django. |
Things to do on this one:
|
Getting this error while running tests:
Versions: |
migrations.RenameIndex( | ||
model_name="taggeditem", | ||
new_name="taggit_tagg_content_8fc721_idx", | ||
old_fields=("content_type", "object_id"), | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using migrations.SeparateDatabaseAndState
might do the trick to do this with zero downtime as explained in this article: https://adamj.eu/tech/2020/07/27/how-to-modernize-your-django-index-definitions/
Why is this not merged yet? |
This is triggering a Django warning
This updates the
index_together
use to resolve this, hopefully painlessly.