#36438: makemigrations removes fields in wrong order when GeneratedFields are involved -------------------------------------+------------------------------------- Reporter: csaska | Owner: (none) Type: | Status: new Cleanup/optimization | Component: Database layer | Version: 5.2 (models, ORM) | Severity: Normal | Resolution: Keywords: | Triage Stage: | Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 1 | UI/UX: 0 -------------------------------------+------------------------------------- Comment (by csaska):
Replying to [ticket:36438 csaska]: > Consider a model like PayItem with fields quantity, rate and total. > > When total is a GeneratedField dependent on quantity, if you remove quantity and total and generate migrations you get a migration like > > > {{{ > operations = [ > migrations.RemoveField( > model_name="payitem", > name="total", > ), > migrations.RemoveField( > model_name="payitem", > name="quantity", > ), > ] > }}} > > which will throw django.db.utils.OperationalError: (3108, "Column 'amount' has a generated column dependency."). > > It'd be nice if makemigrations listed operations in the correct order. In my example, I actually had fields amount, rate and total. Perhaps it using alphabetical order and thus dropping amount operation comes before dropping total operation? -- Ticket URL: <https://code.djangoproject.com/ticket/36438#comment:1> 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 visit https://groups.google.com/d/msgid/django-updates/010701973b9b7717-fb9ec192-b253-4232-a838-c11cf01b5eb9-000000%40eu-central-1.amazonses.com.