Loading django/core/management/commands/makemigrations.py +9 −1 Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ class Command(BaseCommand): help="Create an empty migration.") parser.add_argument('--noinput', action='store_false', dest='interactive', default=True, help='Tells Django to NOT prompt the user for input of any kind.') parser.add_argument('-n', '--name', action='store', dest='name', default=None, help="Use this name for migration file(s).") def handle(self, *app_labels, **options): Loading @@ -36,6 +38,7 @@ class Command(BaseCommand): self.dry_run = options.get('dry_run', False) self.merge = options.get('merge', False) self.empty = options.get('empty', False) self.migration_name = options.get('name', None) # Make sure the app they asked for exists app_labels = set(app_labels) Loading Loading @@ -98,7 +101,11 @@ class Command(BaseCommand): (app, [Migration("custom", app)]) for app in app_labels ) changes = autodetector.arrange_for_graph(changes, loader.graph) changes = autodetector.arrange_for_graph( changes=changes, graph=loader.graph, migration_name=self.migration_name, ) self.write_migration_files(changes) return Loading @@ -107,6 +114,7 @@ class Command(BaseCommand): graph=loader.graph, trim_to_apps=app_labels or None, convert_apps=app_labels or None, migration_name=self.migration_name, ) # No changes? Tell them. Loading django/db/migrations/autodetector.py +5 −5 Original line number Diff line number Diff line Loading @@ -31,14 +31,14 @@ class MigrationAutodetector(object): self.to_state = to_state self.questioner = questioner or MigrationQuestioner() def changes(self, graph, trim_to_apps=None, convert_apps=None): def changes(self, graph, trim_to_apps=None, convert_apps=None, migration_name=None): """ Main entry point to produce a list of appliable changes. Takes a graph to base names on and an optional set of apps to try and restrict to (restriction is not guaranteed) """ changes = self._detect_changes(convert_apps, graph) changes = self.arrange_for_graph(changes, graph) changes = self.arrange_for_graph(changes, graph, migration_name) if trim_to_apps: changes = self._trim_to_apps(changes, trim_to_apps) return changes Loading Loading @@ -951,7 +951,7 @@ class MigrationAutodetector(object): dependencies=dependencies, ) def arrange_for_graph(self, changes, graph): def arrange_for_graph(self, changes, graph, migration_name=None): """ Takes in a result from changes() and a MigrationGraph, and fixes the names and dependencies of the changes so they Loading Loading @@ -985,11 +985,11 @@ class MigrationAutodetector(object): if i == 0 and app_leaf: migration.dependencies.append(app_leaf) if i == 0 and not app_leaf: new_name = "0001_initial" new_name = "0001_%s" % migration_name if migration_name else "0001_initial" else: new_name = "%04i_%s" % ( next_number, self.suggest_name(migration.operations)[:100], migration_name or self.suggest_name(migration.operations)[:100], ) name_map[(app_label, migration.name)] = (app_label, new_name) next_number += 1 Loading docs/ref/django-admin.txt +7 −0 Original line number Diff line number Diff line Loading @@ -683,6 +683,13 @@ written. The ``--merge`` option enables fixing of migration conflicts. .. django-admin-option:: --name, -n .. versionadded:: 1.8 The ``--name`` option allows you to give the migration(s) a custom name instead of a generated one. migrate [<app_label> [<migrationname>]] --------------------------------------- Loading docs/releases/1.8.txt +3 −0 Original line number Diff line number Diff line Loading @@ -228,6 +228,9 @@ Management Commands * The :djadmin:`dbshell` command now supports MySQL's optional SSL certificate authority setting (``--ssl-ca``). * The :djadminopt:`--name` option for :djadmin:`makemigrations` allows you to to give the migration(s) a custom name instead of a generated one. Models ^^^^^^ Loading docs/topics/migrations.txt 100755 → 100644 +7 −0 Original line number Diff line number Diff line Loading @@ -309,6 +309,13 @@ Note that this only works given two things: that your database doesn't match your models, you'll just get errors when migrations try to modify those tables. .. versionadded:: 1.8 If you want to give the migration(s) a meaningful name instead of a generated one, you can use the :djadminopt:`--name` option:: $ python manage.py makemigrations --name changed_my_model your_app_label .. _historical-models: Historical models Loading Loading
django/core/management/commands/makemigrations.py +9 −1 Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ class Command(BaseCommand): help="Create an empty migration.") parser.add_argument('--noinput', action='store_false', dest='interactive', default=True, help='Tells Django to NOT prompt the user for input of any kind.') parser.add_argument('-n', '--name', action='store', dest='name', default=None, help="Use this name for migration file(s).") def handle(self, *app_labels, **options): Loading @@ -36,6 +38,7 @@ class Command(BaseCommand): self.dry_run = options.get('dry_run', False) self.merge = options.get('merge', False) self.empty = options.get('empty', False) self.migration_name = options.get('name', None) # Make sure the app they asked for exists app_labels = set(app_labels) Loading Loading @@ -98,7 +101,11 @@ class Command(BaseCommand): (app, [Migration("custom", app)]) for app in app_labels ) changes = autodetector.arrange_for_graph(changes, loader.graph) changes = autodetector.arrange_for_graph( changes=changes, graph=loader.graph, migration_name=self.migration_name, ) self.write_migration_files(changes) return Loading @@ -107,6 +114,7 @@ class Command(BaseCommand): graph=loader.graph, trim_to_apps=app_labels or None, convert_apps=app_labels or None, migration_name=self.migration_name, ) # No changes? Tell them. Loading
django/db/migrations/autodetector.py +5 −5 Original line number Diff line number Diff line Loading @@ -31,14 +31,14 @@ class MigrationAutodetector(object): self.to_state = to_state self.questioner = questioner or MigrationQuestioner() def changes(self, graph, trim_to_apps=None, convert_apps=None): def changes(self, graph, trim_to_apps=None, convert_apps=None, migration_name=None): """ Main entry point to produce a list of appliable changes. Takes a graph to base names on and an optional set of apps to try and restrict to (restriction is not guaranteed) """ changes = self._detect_changes(convert_apps, graph) changes = self.arrange_for_graph(changes, graph) changes = self.arrange_for_graph(changes, graph, migration_name) if trim_to_apps: changes = self._trim_to_apps(changes, trim_to_apps) return changes Loading Loading @@ -951,7 +951,7 @@ class MigrationAutodetector(object): dependencies=dependencies, ) def arrange_for_graph(self, changes, graph): def arrange_for_graph(self, changes, graph, migration_name=None): """ Takes in a result from changes() and a MigrationGraph, and fixes the names and dependencies of the changes so they Loading Loading @@ -985,11 +985,11 @@ class MigrationAutodetector(object): if i == 0 and app_leaf: migration.dependencies.append(app_leaf) if i == 0 and not app_leaf: new_name = "0001_initial" new_name = "0001_%s" % migration_name if migration_name else "0001_initial" else: new_name = "%04i_%s" % ( next_number, self.suggest_name(migration.operations)[:100], migration_name or self.suggest_name(migration.operations)[:100], ) name_map[(app_label, migration.name)] = (app_label, new_name) next_number += 1 Loading
docs/ref/django-admin.txt +7 −0 Original line number Diff line number Diff line Loading @@ -683,6 +683,13 @@ written. The ``--merge`` option enables fixing of migration conflicts. .. django-admin-option:: --name, -n .. versionadded:: 1.8 The ``--name`` option allows you to give the migration(s) a custom name instead of a generated one. migrate [<app_label> [<migrationname>]] --------------------------------------- Loading
docs/releases/1.8.txt +3 −0 Original line number Diff line number Diff line Loading @@ -228,6 +228,9 @@ Management Commands * The :djadmin:`dbshell` command now supports MySQL's optional SSL certificate authority setting (``--ssl-ca``). * The :djadminopt:`--name` option for :djadmin:`makemigrations` allows you to to give the migration(s) a custom name instead of a generated one. Models ^^^^^^ Loading
docs/topics/migrations.txt 100755 → 100644 +7 −0 Original line number Diff line number Diff line Loading @@ -309,6 +309,13 @@ Note that this only works given two things: that your database doesn't match your models, you'll just get errors when migrations try to modify those tables. .. versionadded:: 1.8 If you want to give the migration(s) a meaningful name instead of a generated one, you can use the :djadminopt:`--name` option:: $ python manage.py makemigrations --name changed_my_model your_app_label .. _historical-models: Historical models Loading