Opened 7 years ago

Closed 3 years ago

#29470 closed New feature (fixed)

Add output to makemigrations and migrate commands with --noinput

Reported by: Kurt Wheeler Owned by: Jacob Walls
Component: Migrations Version: 1.11
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The --noinput option to makemigrations seems to also mean "no output". It would be nice for scripting purposes if there could be some kind of output. When writing a script that helps manage migrations, it would be nice to be able to detect that the migrations needed input from the developer so that the script can fail gracefully and inform the developer that manual intervention is required. Right now the options seem to be to not use the --noinput options and have the prompt interrupt the script, or to use the option and have no idea when migrations failed because they required input.

I'm not very picky as far as how this functionality should be implemented goes. I would think that a little warning like
"No migrations run because input was required but --noinput option was specified."
would be sufficient. This could be output to stdout or stderr, either all the time or perhaps only if an additional option was set.

Change History (10)

comment:1 by Tim Graham, 7 years ago

Resolution: duplicate
Status: newclosed

This looks like a similar request as #29026, even if the proposed implementation is a bit different.

comment:2 by Chris Jerdonek, 3 years ago

From a discussion in a PR for #29026, I think this ticket should be re-opened and handled separately from #29026. My suggestion for addressing this would be to modify the non-interactive questioner so that it logs non-empty output when a question is asked (e.g. saying "Such-and-such question was answered automatically with ..."). This could / should be done using the same output method that the migration command class is using for its logging output.

Version 0, edited 3 years ago by Chris Jerdonek (next)

comment:3 by Jacob Walls, 3 years ago

Has patch: set
Resolution: duplicate
Status: closednew

Like Chris, I believe this should be handled separately. Whereas the idea in #29026 is to move some of makemigrations's current output from stdout to stderr, the error messaging asked for in this ticket should go to stderr regardless, so they don't depend on the changes in #29026.

PR to ~~implement this part of Chris's comment:

In addition, if the answers to one or more questions (provided either automatically from --no-input or manually by the user) cause no migrations to be applied, then the migration command class could log that in any case so the user knows.

I'm in favor of starting with just that change, and only for the non-interactive questioner, i.e. --noinput.

comment:4 by Jacob Walls, 3 years ago

Owner: changed from nobody to Jacob Walls
Status: newassigned

comment:5 by Carlton Gibson, 3 years ago

Triage Stage: UnreviewedAccepted

OK, since there's +2 here, let's take a look at a patch. Thanks.

comment:6 by Mariusz Felisiak, 3 years ago

Patch needs improvement: set

comment:7 by Jacob Walls, 3 years ago

Patch needs improvement: unset

comment:8 by Mariusz Felisiak, 3 years ago

Triage Stage: AcceptedReady for checkin

comment:9 by Mariusz Felisiak <felisiak.mariusz@…>, 3 years ago

In 241ba23:

Refs #29470 -- Added makemigrations test for adding fields with no default and auto_now_add=True in non-interactive mode.

comment:10 by Mariusz Felisiak <felisiak.mariusz@…>, 3 years ago

Resolution: fixed
Status: assignedclosed

In 32f1fe5:

Fixed #29470 -- Logged makemigrations automatic decisions in non-interactive mode.

Note: See TracTickets for help on using tickets.
Back to Top