Watch SQL files directory and automatically reload scripts
Created by: jmealo
Kudos on Massive,
I just ported over pgsanity from Python which uses ecpg to check the syntax of PostgreSQL files. I was thinking that we could have an option that watches the sql files and reloads them automatically as long as there isn't a syntax error (and optionally log/fire an event with a warning/error when a syntax error is encountered, and a notice/log entry when a reload occurs).
Additionally, perhaps we could check the syntax at load when we enumerate them at launch?
I'll try to put my pgsanity port on NPM in the next week or so. The python version used generators and destructuring and so did I. I'll probably remove them so that it doesn't require ES6 functionality (destructuring requires a feature flag still).
Ideally it'd all be streaming but I don't have the time to make it pretty, if it's a live watcher running in process though I think that it'd be wise for nothing to block.
It's wroth noting that ecpg is not included with PostgreSQL or its development libraries. It was available in my path on OSX 10.10 but it's not available on Ubuntu without installing libecpg-dev, so this would need to be a feature flag unless someone uses NAN and wrap libecpg properly... (I don't have time to do this right now.)
Let me know if you're interested.