Commit ab587fa5 authored by Andrew Godwin's avatar Andrew Godwin
Browse files

Add --dry-run option to makemigrations

parent 1d20e6df
Loading
Loading
Loading
Loading
+17 −15
Original line number Diff line number Diff line
@@ -14,17 +14,18 @@ from django.db.models.loading import cache

class Command(BaseCommand):
    option_list = BaseCommand.option_list + (
        make_option('--empty', action='store_true', dest='empty', default=False,
            help='Make a blank migration.'),
        make_option('--dry-run', action='store_true', dest='dry_run', default=False,
            help="Just show what migrations would be made; don't actually write them."),
    )

    help = "Creates new migration(s) for apps."
    usage_str = "Usage: ./manage.py makemigrations [--empty] [app [app ...]]"
    usage_str = "Usage: ./manage.py makemigrations [--dry-run] [app [app ...]]"

    def handle(self, *app_labels, **options):

        self.verbosity = int(options.get('verbosity'))
        self.interactive = options.get('interactive')
        self.dry_run = options.get('dry_run', False)

        # Make sure the app they asked for exists
        app_labels = set(app_labels)
@@ -73,6 +74,7 @@ class Command(BaseCommand):
                    for operation in migration.operations:
                        self.stdout.write("    - %s\n" % operation.describe())
                # Write it
                if not self.dry_run:
                    migrations_directory = os.path.dirname(writer.path)
                    if not directory_created.get(app_label, False):
                        if not os.path.isdir(migrations_directory):