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 , 10 years ago
comment:2 by , 10 years ago
Severity: | Normal → Release blocker |
---|---|
Triage Stage: | Unreviewed → Accepted |
If we don't choose to backport the fix to 1.7, we should correct the documentation.
comment:3 by , 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:6 by , 10 years ago
Severity: | Release blocker → Normal |
---|
comment:7 by , 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 , 10 years ago
Easy pickings: | set |
---|---|
Keywords: | sprint ams2015 added |
comment:9 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:11 by , 10 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:12 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
I'll also note that the current documentation for
makemigrations
[1] is incorrect since it states:Which is incorrect.
[1] https://docs.djangoproject.com/en/1.7/ref/django-admin/#django-admin-makemigrations