#31665: Auto-migrations fail on postgres when Charfield's default value is longer than old constraint -------------------------------------+------------------------------------- Reporter: shadytradesman | Owner: nobody Type: Bug | Status: closed Component: Migrations | Version: 2.2 Severity: Normal | Resolution: wontfix Keywords: charfield resize | Triage Stage: default alterfield max_length | Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Changes (by Simon Charette):
* status: new => closed * resolution: => wontfix Comment: > This migration worked on mysql when I was developing locally, but it was because I updated the random_string() function to provide a string that was longer after I ran the migration. If you alter a function referenced by historical migration you need to make sure the existing operations referencing the function are repointed to a valid definition. By changing the return of `random_string` you happened to make `0004_auto_20200529_2006` migration invalid. In your case that means you should have copied your old version of `random_string` that returned a string of length 7 to `0004_auto_20200529_2006` add adjust the `AddField` operation to point to it instead of the altered `cells.models.random_string`. -- Ticket URL: <https://code.djangoproject.com/ticket/31665#comment:4> 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/072.7d863ebee345c92037754bd6e259c969%40djangoproject.com.