Opened 2 years ago

Closed 19 months ago

#23407 closed Cleanup/optimization (fixed)

makemigrations doesn't use --noinput

Reported by: Baptiste Mispelon Owned by: Marten Kenbeek
Component: Migrations Version: 1.7
Severity: Normal Keywords: sprint ams2015
Cc: Triage Stage: Ready for checkin
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no


#22862 added the --noinput to the makemigrations command but only when using --merge.

It seems to me that it would be a useful addition to the plain makemigrations too and could work like this:

  • If the migrations can be created without user input, create it
  • If not, raise an error.

I tried changing the code to use MigrationQuestioner instead of InteractiveMigrationQuestioner but it seems that this just creates a migration with default=None which might not be what you want.

Implementing a new questioner object like this seems to work in my limited testcase:

class NonInteractiveQuestioner(MigrationQuestioner):
    def ask_not_null_addition(self, field_name, model_name):
        raise NotImplementedError

    def ask_rename(self, model_name, old_name, new_name, field_instance):
        raise NotImplementedError

    def ask_rename_model(self, old_model_state, new_model_state):
        raise NotImplementedError

    def ask_merge(self, app_label):
        raise NotImplementedError

Change History (12)

comment:1 Changed 2 years ago by Baptiste Mispelon

I'll also note that the current documentation for makemigrations [1] is incorrect since it states:

The --noinput option may be provided to suppress all user prompts.

Which is incorrect.


comment:2 Changed 2 years ago by Tim Graham

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

If we don't choose to backport the fix to 1.7, we should correct the documentation.

comment:3 Changed 2 years ago by Andrew Godwin

Agree that implementing a new questioner is the best way, though I think some of the questions we can give sensible answers to (e.g. rename, rename_model should probably just be False as rename detection is not guaranteed anyway)

comment:4 Changed 2 years ago by Tim Graham <timograham@…>

In 450a61600407d7320b85b75b441ce67b199da68b:

Corrected --noinput docs for makemigrations; refs #23407.

comment:5 Changed 2 years ago by Tim Graham <timograham@…>

In 40e5eb4114e66dfaacea162fc9f39c0618dcfad9:

[1.7.x] Corrected --noinput docs for makemigrations; refs #23407.

Backport of 450a616004 from master

comment:6 Changed 2 years ago by Tim Graham

Severity: Release blockerNormal

comment:7 Changed 20 months ago by karyon

there is also " makemigrations --help" which tells the user

"--noinput             Tells Django to NOT prompt the user for input of any kind."

comment:8 Changed 19 months ago by Markus Holtermann

Easy pickings: set
Keywords: sprint ams2015 added

comment:9 Changed 19 months ago by Marten Kenbeek

Owner: changed from nobody to Marten Kenbeek
Status: newassigned

comment:11 Changed 19 months ago by Markus Holtermann

Triage Stage: AcceptedReady for checkin

comment:12 Changed 19 months ago by Markus Holtermann <info@…>

Resolution: fixed
Status: assignedclosed

In e272904ff7cc4d138e316ba2e7811666053860a4:

Fixed #23407 -- Extended coverage of makemigrations --noinput option.

Changed --noinput option in makemigrations to suppress all user prompts,
not just when combined with --merge.

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