Opened 10 years ago

Closed 10 years 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

Description

#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 by Baptiste Mispelon, 10 years ago

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.

[1] https://docs.djangoproject.com/en/1.7/ref/django-admin/#django-admin-makemigrations

comment:2 by Tim Graham, 10 years ago

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 by Andrew Godwin, 10 years ago

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 by Tim Graham <timograham@…>, 10 years ago

In 450a61600407d7320b85b75b441ce67b199da68b:

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

comment:5 by Tim Graham <timograham@…>, 10 years ago

In 40e5eb4114e66dfaacea162fc9f39c0618dcfad9:

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

Backport of 450a616004 from master

comment:6 by Tim Graham, 10 years ago

Severity: Release blockerNormal

comment:7 by karyon, 10 years ago

there is also "manage.py makemigrations --help" which tells the user

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

comment:8 by Markus Holtermann, 10 years ago

Easy pickings: set
Keywords: sprint ams2015 added

comment:9 by Marten Kenbeek, 10 years ago

Owner: changed from nobody to Marten Kenbeek
Status: newassigned

comment:11 by Markus Holtermann, 10 years ago

Triage Stage: AcceptedReady for checkin

comment:12 by Markus Holtermann <info@…>, 10 years ago

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