Opened 2 years ago
Last modified 2 years ago
#34052 closed Bug
migrate --check still emits signals if database is up to date — at Initial Version
Reported by: | Jacob Walls | Owned by: | nobody |
---|---|---|---|
Component: | Migrations | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
pre_migrate
and post_migrate
signals are emitted for migrate --check
, but only if the database is up-to-date.
A related side effect is that the logs also look like a like a real run, as it says "Operations to perform:" and "Running migrations:". The last sentence clarifies that nothing has been applied, but there is still the potential for a half-second of "what have I just done?".
% python manage.py migrate --check Operations to perform: Apply all migrations: admin, auth, contenttypes, sessions, social_django Running migrations: No migrations to apply.
I think the patch is as simple as:
diff --git a/django/core/management/commands/migrate.py b/django/core/management/commands/migrate.py index d98072c66e..f1b8a21c11 100644 --- a/django/core/management/commands/migrate.py +++ b/django/core/management/commands/migrate.py @@ -237,7 +237,7 @@ class Command(BaseCommand): self.stdout.write(" No migrations to prune.") plan = executor.migration_plan(targets) - exit_dry = plan and options["check_unapplied"] + exit_dry = options["check_unapplied"] if options["plan"]: self.stdout.write("Planned operations:", self.style.MIGRATE_LABEL)
Note:
See TracTickets
for help on using tickets.