database_consistency icon indicating copy to clipboard operation
database_consistency copied to clipboard

All checks unexpectedly pass when database is unavailable

Open gravitystorm opened this issue 1 year ago • 1 comments

I just found out that I set up our CI incorrectly (my bad!), and there was no database connection available when running our database_consistency checks.

So I was surprised to find that CI passed! This is because every model is ignored, and therefore bundle exec database_consistency exits with 0 i.e. successfully.

Loaded configurations: .database_consistency.yml
ApplicationRecord doesn't have active connection: ignoring
User doesn't have active connection: ignoring
Product doesn't have active connection: ignoring
...

I think it would be better if the checks fail when there's unexpectedly no connection at all, so that CI doesn't give false reassurances!

I researched a bit and found https://github.com/djezzzl/database_consistency/pull/213 but I'm not sure what the motivation was for ignoring disconnected models, so I'm not sure how to balance the two situations.

gravitystorm avatar Aug 30 '24 14:08 gravitystorm

Hi @gravitystorm,

There is no balance; it is only preference, I guess. We may introduce a configuration that changes the behavior, but it's an open question that should be defaulted.

Would you like to introduce such?

djezzzl avatar Oct 10 '24 17:10 djezzzl

Hi @gravitystorm,

I will close the proposal for now, but I'm open to discussing it again if more people need it or if somebody is willing to implement it.

djezzzl avatar Dec 26 '24 14:12 djezzzl