#30431: Migration hangs on non default database. -------------------------------------+------------------------------------- Reporter: mandm | Owner: nobody Type: Bug | Status: closed Component: Migrations | Version: master Severity: Normal | Resolution: Keywords: migrations, uuid, | worksforme uuidfield, database router, | Triage Stage: multiple database | Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Changes (by felixxm):
* status: new => closed * version: 1.11 => master * resolution: => worksforme Comment: Thanks for the report, but described case works for me. First of all you should use `schema_editor.connection.alias` in `gen_uuid()` to fix it for multiple databases (see [https://docs.djangoproject.com/en/stable/ref/migration- operations/#runpython RunPython]), .e.g. {{{#!python def gen_uuid(apps, schema_editor): UserModel = apps.get_model('myapp', 'customuser') db_alias = schema_editor.connection.alias for row in UserModel.objects.using(db_alias).all(): row.uniq_id = uuid.uuid4() row.save(update_fields=['uniq_id']) }}} Secondly in mentioned documentation we have three separate migrations not one. It depends on database but in e.g. PostgreSQL you will not be able to alter column and update date in a single transaction. My advice is to split migration files and use `schema_editor.connection.alias`. Please use one of [https://code.djangoproject.com/wiki/TicketClosingReasons/UseSupportChannels support channels] if you need furher help. -- Ticket URL: <https://code.djangoproject.com/ticket/30431#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 post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/063.0bb45314680e24339a7ec518522f8fb0%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.