SACGF / variantgrid

VariantGrid public repo
Other
23 stars 2 forks source link

CITextField deprecated - waiting for 4.3.1 (will be removed in Django 5.1) #831

Open davmlaw opened 1 year ago

davmlaw commented 1 year ago
genes.GeneSymbol.symbol: (fields.W907) django.contrib.postgres.fields.CITextField is deprecated. Support for it (except in historical migrations) will be removed in Django 5.1.
    HINT: Use TextField(db_collation="…") with a case-insensitive non-deterministic collation instead.
genes.GeneSymbolAlias.alias: (fields.W907) django.contrib.postgres.fields.CITextField is deprecated. Support for it (except in historical migrations) will be removed in Django 5.1.
    HINT: Use TextField(db_collation="…") with a case-insensitive non-deterministic collation instead.

https://docs.djangoproject.com/en/4.2/ref/contrib/postgres/operations/#manage-postgresql-collations

https://adamj.eu/tech/2023/02/23/migrate-django-postgresql-ci-fields-case-insensitive-collation/

davmlaw commented 1 year ago

I followed the steps above, and it failed:

django.db.utils.NotSupportedError: nondeterministic collations are not supported for operator class "text_pattern_ops"

This has been reported and fixed, but has not been released yet (isn't in 4.2.2)

I'll disable the warnings for now...

davmlaw commented 1 month ago

1st we need to work out what version migrations will work on

Here are the actively updating server Django versions

Server Django version
variantgrid.com 4.2.10
test.variantgrid.com 4.2.14
shariant.org.au 4.2.11
test.shariant.org.au 4.2.11
demo.shariant.org.au 4.2.11

(JA: Side note, I wonder if it's worth putting the Django version as an admin only field on the versions page)

TheMadBug commented 1 month ago

@davmlaw I've filled in the Django versions of the Shariant environments

davmlaw commented 1 month ago

JA: Side note, I wonder if it's worth putting the Django version as an admin only field on the versions page

Yeah I went and looked hoping it was there - spun off into mini issue SACGF/variantgrid#1129

davmlaw commented 1 month ago

It is fixed in 4.2 but only for new ones https://code.djangoproject.com/ticket/33901#comment:17

This fix indeed only solves the problem when you first time creating model fields with collation and prevents pattern ops index created

So - I had to do a few migrations to rename symbol to "old_symbol", make a new one, copy across, delete old, change PK

davmlaw commented 1 month ago

testing: should be no visible change - gene names should remain case insensitive

I searched for GaTa2 and brCa1 and ti worked as before

davmlaw commented 1 month ago

https://adamj.eu/tech/2023/02/23/migrate-django-postgresql-ci-fields-case-insensitive-collation/#adjust-queries

If you find errors like:

NotSupportedError: nondeterministic collations are not supported for LIKE

I added get_deterministic_queryset which annotated symbol_deterministic which you can perform likes on