Fixed #14300 -- Fixed initial SQL location if models is a directory.

Previously myapp/models/sql/ would be searched; now it's myapp/sql/ as documented.

Thanks al_the_x for the report and fheinz for the draft patch.
Added backwards compatibility and refactored logic to use AppCache