sails-migrations
sails-migrations copied to clipboard
Environment information not properly propagated through to configuration loading
In attempting to migrate new changes into the production DB for the first time, it was realized that the environment information isn't handled properly.
A workaround for the issue is:
NODE_ENV=production sails-migrations migrate
The issue appears to be that the configuration pulls in the default configuration under the assumption that the environment is development, not production, despite whether or not someone is using the '--env' flag. This was confirmed by running the following script to print out what the application is seeing:
const SailsIntegration = require('./node_modules/sails-migrations/lib/sails-migrations/helpers/sails_integration');
const path = require('path');
var modulesPath = path.join(process.cwd(), 'node_modules');
SailsIntegration.loadSailsConfig(modulesPath, function(err, cache) {
console.log(cache);
});
For me, this was resulting in a connection refused error (ECONNREFUSED).
@karma0 Just took a quick peek, and it seems to not set the env. It does specify it as an option, but then doesn't use it.
I'm not sure how this should work. Perhaps it should be the third option (default) for commander, and perhaps it should be used to set the env in the config. It might be a while before I have time to look at this. A PR is more than welcome though :)