mirror of https://github.com/django/django.git
Fixed #25063 -- Added path to makemigration's output of migration file.
This commit is contained in:
parent
e090070761
commit
99a1265a39
|
@ -172,7 +172,12 @@ class Command(BaseCommand):
|
||||||
# Describe the migration
|
# Describe the migration
|
||||||
writer = MigrationWriter(migration)
|
writer = MigrationWriter(migration)
|
||||||
if self.verbosity >= 1:
|
if self.verbosity >= 1:
|
||||||
self.stdout.write(" %s:\n" % (self.style.MIGRATE_LABEL(writer.filename),))
|
# Display a relative path if it's below the current working
|
||||||
|
# directory, or an absolute path otherwise.
|
||||||
|
migration_string = os.path.relpath(writer.path)
|
||||||
|
if migration_string.startswith('..'):
|
||||||
|
migration_string = writer.path
|
||||||
|
self.stdout.write(" %s:\n" % (self.style.MIGRATE_LABEL(migration_string),))
|
||||||
for operation in migration.operations:
|
for operation in migration.operations:
|
||||||
self.stdout.write(" - %s\n" % operation.describe())
|
self.stdout.write(" - %s\n" % operation.describe())
|
||||||
if not self.dry_run:
|
if not self.dry_run:
|
||||||
|
|
|
@ -227,7 +227,7 @@ You should see something similar to the following:
|
||||||
.. code-block:: text
|
.. code-block:: text
|
||||||
|
|
||||||
Migrations for 'polls':
|
Migrations for 'polls':
|
||||||
0001_initial.py:
|
polls/migrations/0001_initial.py:
|
||||||
- Create model Choice
|
- Create model Choice
|
||||||
- Create model Question
|
- Create model Question
|
||||||
- Add field question to choice
|
- Add field question to choice
|
||||||
|
|
|
@ -239,7 +239,7 @@ create a database migration:
|
||||||
|
|
||||||
$ python manage.py makemigrations
|
$ python manage.py makemigrations
|
||||||
Migrations for 'world':
|
Migrations for 'world':
|
||||||
0001_initial.py:
|
world/migrations/0001_initial.py:
|
||||||
- Create model WorldBorder
|
- Create model WorldBorder
|
||||||
|
|
||||||
Let's look at the SQL that will generate the table for the ``WorldBorder``
|
Let's look at the SQL that will generate the table for the ``WorldBorder``
|
||||||
|
|
|
@ -199,6 +199,9 @@ Management Commands
|
||||||
command exit with a non-zero status when model changes without migrations are
|
command exit with a non-zero status when model changes without migrations are
|
||||||
detected.
|
detected.
|
||||||
|
|
||||||
|
* :djadmin:`makemigrations` now displays the path to the migration files that
|
||||||
|
it generates.
|
||||||
|
|
||||||
Migrations
|
Migrations
|
||||||
^^^^^^^^^^
|
^^^^^^^^^^
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ a field and remove a model - and then run :djadmin:`makemigrations`::
|
||||||
|
|
||||||
$ python manage.py makemigrations
|
$ python manage.py makemigrations
|
||||||
Migrations for 'books':
|
Migrations for 'books':
|
||||||
0003_auto.py:
|
books/migrations/0003_auto.py:
|
||||||
- Alter field author on book
|
- Alter field author on book
|
||||||
|
|
||||||
Your models will be scanned and compared to the versions currently
|
Your models will be scanned and compared to the versions currently
|
||||||
|
|
|
@ -1009,6 +1009,18 @@ class MakeMigrationsTests(MigrationTestBase):
|
||||||
with self.temporary_migration_module(module="migrations.test_migrations_no_changes"):
|
with self.temporary_migration_module(module="migrations.test_migrations_no_changes"):
|
||||||
call_command("makemigrations", "--check", "migrations", verbosity=0)
|
call_command("makemigrations", "--check", "migrations", verbosity=0)
|
||||||
|
|
||||||
|
def test_makemigrations_migration_path_output(self):
|
||||||
|
"""
|
||||||
|
makemigrations should print the relative paths to the migrations unless
|
||||||
|
they are outside of the current tree, in which case the absolute path
|
||||||
|
should be shown.
|
||||||
|
"""
|
||||||
|
out = six.StringIO()
|
||||||
|
apps.register_model('migrations', UnicodeModel)
|
||||||
|
with self.temporary_migration_module() as migration_dir:
|
||||||
|
call_command("makemigrations", "migrations", stdout=out)
|
||||||
|
self.assertIn(os.path.join(migration_dir, '0001_initial.py'), out.getvalue())
|
||||||
|
|
||||||
|
|
||||||
class SquashMigrationsTests(MigrationTestBase):
|
class SquashMigrationsTests(MigrationTestBase):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue