I've got a very strange issue that I'd like some advice on. I have an existing, well-established sails app using Sails 1.0.2 (originally created using 0.13 and upgraded), sails-postgresql@1.0.0-13. For quite a while now, the app has had 9 models (all using pg). I'm now trying to add three more. Since we don't like automigrations, I created these in postgres, then created models for sails based on the postgres table using sails generate model. These models appear very similar to the ones that already exist.
However, if I try to do a simple query, I get some very strange errors. (Note that "User" is one of my pre-existing models, not one of the new ones -- so this is apparently taking out the whole orm hook.)
sails> User.find().then(console.log)
Promise {
_bitField: 0,
_fulfillmentHandler0: undefined,
_rejectionHandler0: undefined,
_promise0: undefined,
_receiver0: undefined }
sails> Unhandled rejection AdapterError: Unexpected error from database
adapter: Could not run select() because of 2 problems:
------------------------------------------------------
• "datastore" is required, but it was not defined.
• "models" is required, but it was not defined.
------------------------------------------------------
If I remove the new model files, this works fine. If the files are present (even if the entire content is commented out or all the properties of the model are commented out!) I get the same error. I've tried recreating and simplifying the tables (since I used some advanced Postgres features) but that did nothing.
The only thing I've found that makes any difference is if I add the "datastore" attribute to the new models. In that case, I can query the "old" models but get the same error when I try to query a new one.
I've confirmed that all my settings in config/models.js
& config/datastores.js
look right.