Decache database tables on close
The problem
Since tables can be loaded using require()
and since requires are cached, if a database is closed and then re-opened within the same process (e.g., if a server is restarted without reloading the whole app), the tables will be replaced with their cached versions, thereby losing any new changes since the process started.
Clearly, this is not what we want ;)
Proposed solution
Decache all table paths during a database close.