Opened 19 months ago

Closed 19 months ago

Last modified 18 months ago

#34632 closed Cleanup/optimization (wontfix)

Let makemigrations output an error message with --check

Reported by: Jakob Probst Owned by: nobody
Component: Migrations Version: 4.2
Severity: Normal Keywords:
Cc: Jacob Walls Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

With the PR 15845 regarding the Issue #34051 the option --check does not output any errors when changes have been detected. This seems counter intuitive for at least unix users. Command line tools for unix typically do not output anything if everything goes well but print an error message if something went wrong. Furthermore if the command is run in a pipeline it is not possible to know for certain if the command failed because of a wrongly set up pipeline job or if a migration is actually missing. Outputting the detected changes also leverages the person looking into the pipeline job to know what is missing without the need to check out the changes and actually create the migration, thus giving the person the opportunity to make further decisions. A possible solution could be to make the flag --check imply the flag --dry-run and move the if check_changes: back down.

Change History (5)

comment:1 by Mariusz Felisiak, 19 months ago

Cc: Jacob Walls added
Resolution: wontfix
Status: newclosed

Thanks for the report (partly related with #34436), however, this is a documented and intended change.

Furthermore if the command is run in a pipeline it is not possible to know for certain if the command failed because of a wrongly set up pipeline job or if a migration is actually missing.

You can always check a status code. I don't think outputting an error message will improve it somehow.

Please first start a discussion on the DevelopersMailingList, where you'll reach a wider audience and see what other think, and follow the triaging guidelines with regards to wontfix tickets.

comment:2 by David Sanders, 19 months ago

This is also related to #34457: makemigrations --check no longer prints the changes.

A possible solution could be to make the flag --check imply the flag --dry-run

This is what I was proposing in my PR :P

comment:3 by Jakob Probst, 19 months ago

Did you you open a discussion on the developer mailing list?

in reply to:  3 comment:4 by David Sanders, 19 months ago

Replying to Jakob Probst:

Did you you open a discussion on the developer mailing list?

Nope, feel free to start a discussion 👍

comment:5 by Lukas von Allmen, 18 months ago

We encountered the same issue as we used the command in our gitlab pipeline and relied on the output to inform the developer what went wrong.
We solved it like this:

test:
  script:
    - ...
    - pipenv run python manage.py makemigrations --check || echo "Your models have changes that are not yet reflected in a migration. Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them." && false
    - ...

But I guess it's a bit too specific for adding to the documentation.

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