Closed venkatd closed 1 week ago
Yeah, that's fair... 🤔 It's something that I had on my mind but avoided in the first draft because it felt a bit complicated.
I could even see just removing the unused triggers on startup instead of just logging. That might get people into trouble if they start having multiple nodes pointing to the same database and having different watchers setup (so each node might delete the other node's watchers). But if people ever want to get that advanced then there could probably be something like a automatically_delete_triggers: false
option (where the default is true
) 🤔
I can take a look at the auto-removing tomorrow and see how complicated it is 👍
I introduced the ability to do this in the latest versions, so check it out (heads up to @rogelio2k )
Be sure to check out the library's new HexDocs which include upgrade guides for some recent breaking changes!
Quick note on that also: by default ecto_watch
will log unused triggers and functions. You'll need to use set the ECTO_WATCH_CLEANUP
environment variable to cleanup
to actually do the cleanup (though I suggest just seeing what the logs say first)
I don't know the best approach here, but if I test out EctoWatch on a specific schema, then remove it from the list, the trigger still remains.
I had to manually run a
DROP TRIGGER
function.For performance reasons, it would be best to remove unused triggers.
Thoughts on the best way to handle this?
Perhaps a Logger.warn to detect unused triggers/functions with the
ew_
prefix?