migra
migra copied to clipboard
return 2, but why ?
Hello, When I run migra with the option "--with-privileges" (there are also the options --unsafe --schema public, but not relevant), the tool returns error code 2 without error messages. The sql file is however well created and functional. How can I get more informations about the reason (debug or other)?
Cheers for the question. There's no error as such, the error codes are designed to match unix's diff
command, which returns zero if there are no differences but no-zero if there are.
This isn't super obvious, and should probably be better documented somewhere.
Great explanation.
As an aside, it might be nice to have a --ci
parameter or something that returns 0 unless there is an error; most CI systems will choke on a status code of 2 (which is why I'm here) :)
This is very much the same as Django ticket #25604 (Add --check flag to makemigrations; return 0 exit status for no new migrations) and my suggestion is to follow their proposal:
Proposal: add
--check
flag to themakemigrations
management command. This flag will return 0 if no new migrations will be created. It will return non-zero if models contain changes without migrations. This will deprecrate the--exit
flag originally discussed here: https://groups.google.com/forum/#!topic/django-developers/I3M6B-wYYd8/discussion. The problem with--exit
is that it return the opposite exit status from what continuous integration servers typically expect.
In the context of migra, the --check
argument should cause error codes matching the diff
command to be returned, otherwise the normal behaviour should be zero if everything worked OK, or non-zero if there were errors.
To add a vote for this: I'd like to use this tool from a Makefile, but the nonzero exit causes make to abort.