Artur-Sulej / excellent_migrations

An Elixir tool for checking safety of database migrations.
MIT License
232 stars 25 forks source link

Non-zero status is not returned when safety checks fail #22

Open iamvery opened 1 year ago

iamvery commented 1 year ago

Problem

I noticed that despite the implementation, the Mix task does not appear to return a non-zero exit status when dangers are found. Here's an example:

» mix excellent_migrations.check_safety; echo $status

09:08:12.638 [warning] Index not concurrently in priv/repo/migrations/20230103220859_testing-stuff.exs:5
0

Note: Echo'd status is 0.

Solution

I'm not certain why this is an issue, but I'm guessing that perhaps System.stop(1) isn't behaving as expected with Mix? Perhaps there's another way to return non-zero status from Mix, such as raising an error after logging dangers, https://hexdocs.pm/mix/Mix.html#raise/2.