Put module.exports.models In local.js

22 views
Skip to first unread message

Paul Tiseo

unread,
Feb 23, 2015, 10:31:30 AM2/23/15
to sai...@googlegroups.com
Can I put a module.exports.models or .connection in local.js? Makes more sense as connections (esp. pwds) and databases may vary from machine to machine.

If so, is it ok to comment out the same in the models.js and connections.js files?

Robert Main

unread,
Feb 23, 2015, 12:45:14 PM2/23/15
to Paul Tiseo, sai...@googlegroups.com

The recommended way to do it is to have local.js uncommitted and gitignored on your local machine. Then in connection.js use process.env to fetch environment variables which is what will be used in production.

Paul Tiseo

unread,
Feb 23, 2015, 12:54:51 PM2/23/15
to sai...@googlegroups.com, paulx...@gmail.com
Actually, we have dev (CI) and prod boxes, plus each dev develops locally at first. So, the way SailsJS does it doesn't suit us, I think. (Unless we gitignore the development.js file.)

I am asking because I did move module.exports.models into local.js, but now Sails asks me to set the migrate setting on every lift.

Robert Main

unread,
Feb 23, 2015, 1:01:33 PM2/23/15
to Paul Tiseo, sai...@googlegroups.com

Your CI boxes should be used for running tests, in which case your actual database stuff should be mocked out. In not super sure how tests fit together with sails but someone else likely will. Falling that, just provide environment variables. If each dev develops locally they should have their own local.js, which is also gitignored and uncommitted. Ideally no passwords should be in version control.

Reply all
Reply to author
Forward
0 new messages