#33901: non-deterministic collations doesn't work with Unique=True on Postgres13.3 -------------------------------------+------------------------------------- Reporter: Ed Chai | Owner: Ed Chai Type: Bug | Status: closed Component: Migrations | Version: dev Severity: Normal | Resolution: fixed Keywords: collation unique | Triage Stage: Ready for citext | checkin Has patch: 1 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Changes (by Mariusz Felisiak):
* status: new => closed * resolution: => fixed Comment: Replying to [comment:18 Adam]: > the issues can be recreated as follows: > > I have an old migration that sets the field with unique=true > > I have a new migration that sets the field with unique=true, db_collation="utf8_unicode_ci" > > The old migration runs first, and creates a LIKE index for the field. The new migration attempts to run: > {{{ > django.db.utils.NotSupportedError: nondeterministic collations are not supported for operator class "varchar_pattern_ops" > }}} > > > My work around is writing a DROP INDEX of the LIKE index that is created by the first migration > > {{{ > migrations.RunSQL( > sql="DROP INDEX IF EXISTS appname_modelname_fieldname_073c92ac_like;", > reverse_sql=migrations.RunSQL.noop, > ), > migrations.AlterField( > model_name="modelname", > name="fieldname", > field=models.CharField( > blank=True, db_collation="utf8_unicode_ci", max_length=255, null=True, unique=True > ), > ), > }}} > > But this is quite messy. Thanks for the report. In the future, please open new tickets for linked bug reports and don't reopen already closed. I've created #34898. -- Ticket URL: <https://code.djangoproject.com/ticket/33901#comment:19> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/0107018b1cdf6268-e45fc349-7475-411f-a481-306e376835b8-000000%40eu-central-1.amazonses.com.