[Django] #34052: migrate --check still emits signals if database is up to date

22 views
Skip to first unread message

Django

unread,
Sep 25, 2022, 1:18:22 AM9/25/22
to django-...@googlegroups.com
#34052: migrate --check still emits signals if database is up to date
---------------------------------------+------------------------
Reporter: Jacob Walls | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: dev
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
---------------------------------------+------------------------
`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)
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/34052>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 26, 2022, 2:04:51 AM9/26/22
to django-...@googlegroups.com
#34052: migrate --check still emits signals if database is up to date
-----------------------------+------------------------------------

Reporter: Jacob Walls | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by Mariusz Felisiak):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/34052#comment:1>

Django

unread,
Sep 26, 2022, 6:43:08 AM9/26/22
to django-...@googlegroups.com
#34052: migrate --check still emits signals if database is up to date
-----------------------------+------------------------------------
Reporter: Jacob Walls | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-----------------------------+------------------------------------

Comment (by JunKi Yoon):

Replying to [ticket:34052 Jacob Walls]:

Can I try this ticket?

--
Ticket URL: <https://code.djangoproject.com/ticket/34052#comment:2>

Django

unread,
Sep 26, 2022, 6:53:03 AM9/26/22
to django-...@googlegroups.com
#34052: migrate --check still emits signals if database is up to date
-----------------------------+--------------------------------------
Reporter: Jacob Walls | Owner: JunKi Yoon
Type: Bug | Status: assigned

Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-----------------------------+--------------------------------------
Changes (by JunKi Yoon):

* owner: nobody => JunKi Yoon
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/34052#comment:3>

Django

unread,
Sep 26, 2022, 10:03:34 AM9/26/22
to django-...@googlegroups.com
#34052: migrate --check still emits signals if database is up to date
-----------------------------+--------------------------------------
Reporter: Jacob Walls | Owner: JunKi Yoon
Type: Bug | Status: assigned
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-----------------------------+--------------------------------------
Changes (by JunKi Yoon):

* has_patch: 0 => 1


Comment:

I added patch :)
[https://github.com/django/django/pull/16120 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/34052#comment:4>

Django

unread,
Sep 26, 2022, 3:42:27 PM9/26/22
to django-...@googlegroups.com
#34052: migrate --check still emits signals if database is up to date
-----------------------------+--------------------------------------
Reporter: Jacob Walls | Owner: JunKi Yoon
Type: Bug | Status: assigned
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1

Easy pickings: 1 | UI/UX: 0
-----------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 0 => 1
* needs_tests: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/34052#comment:5>

Django

unread,
Sep 27, 2022, 7:51:12 AM9/27/22
to django-...@googlegroups.com
#34052: migrate --check still emits signals if database is up to date
-----------------------------+--------------------------------------
Reporter: Jacob Walls | Owner: JunKi Yoon
Type: Bug | Status: assigned
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-----------------------------+--------------------------------------
Description changed by Jacob Walls:

Old description:

New 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.
}}}

--

--
Ticket URL: <https://code.djangoproject.com/ticket/34052#comment:6>

Django

unread,
Sep 27, 2022, 2:58:39 PM9/27/22
to django-...@googlegroups.com
#34052: migrate --check still emits signals if database is up to date
-----------------------------+---------------------------------------------

Reporter: Jacob Walls | Owner: JunKi Yoon
Type: Bug | Status: assigned
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-----------------------------+---------------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 1 => 0
* needs_tests: 1 => 0
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/34052#comment:7>

Django

unread,
Sep 27, 2022, 3:38:44 PM9/27/22
to django-...@googlegroups.com
#34052: migrate --check still emits signals if database is up to date
-----------------------------+---------------------------------------------
Reporter: Jacob Walls | Owner: JunKi Yoon
Type: Bug | Status: closed
Component: Migrations | Version: dev
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-----------------------------+---------------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"1a7b6909ac030d2c4dae2664b08ee0bce9c4c915" 1a7b690]:
{{{
#!CommitTicketReference repository=""
revision="1a7b6909ac030d2c4dae2664b08ee0bce9c4c915"
Fixed #34052 -- Made migrate --check don't emit signals and output when up
to date.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/34052#comment:8>

Reply all
Reply to author
Forward
0 new messages