#23347: Add --dry-run to migrate -----------------------------+---------------------- Reporter: Naddiseo | Owner: nobody Type: New feature | Status: new Component: Migrations | Version: 1.7-rc-3 Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Easy pickings: 0 | UI/UX: 0 -----------------------------+---------------------- In a similar vein to https://code.djangoproject.com/ticket/23263, I would like to propose that a "--dry-run" or "--check" be added to the `migrate` command. Basically, I want to be able to run through the migrations without it making database changes, so that I can see if I've broken something, especially if I'm writing a migration with a `RunPython`.
Another way I can see this working, is if sqlmigrate could also output all the sql that was issued, including those issued by `RunPython`, so that if I had the following migration [#migration '[0]'] it would output something similar to [#output '[1]'] [=#migration [0]] Migration: {{{#!python # -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations def update_contenttypes(apps, schema_editor): ContentType = apps.get_models('contenttypes', 'ContentType') ContentType.objects.get(pk = 1) class Migration(migrations.Migration): dependencies = [ ('everdeal', '0001_initial'), ] operations = [ migrations.RunPython(update_contenttypes) ] }}} [=#output [1]] Output: {{{#!bash BEGIN; -- -- MIGRATION NOW PERFORMS OPERATION THAT CANNOT BE WRITTEN AS SQL: -- Raw Python operation SELECT * FROM contenttypes_contenttype WHERE id=1; -- ROLLBACK; }}} -- Ticket URL: <https://code.djangoproject.com/ticket/23347> 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/051.ebf554e0f5401a6df627898b3ad7a4bc%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.