Dave
Dave

Reputation: 2190

How to migrate models in production mode with SailsJS and MongoDB

I developed a web application with the MVC SailsJS (Version 1.1.0) framework, based on node js. I released it in production mode but every time I release an update from development to production I don't know how to do that.

This, because in development I can execute the sails lift -alter command that independently modifies the models and adapts them to new modifications, but in production this command is blocked.

What is the best way to take? Should I create scripts in MongoDB where I manually change the collections?

Upvotes: 2

Views: 772

Answers (2)

Mwase
Mwase

Reputation: 1032

You can change the environment in your current terminal session.

-- NOTE -- I do not recommend altering your database in production because you might lose data. Do this at your own risk.

export NODE_ENV=development run in the terminal

Then do your thing sails lift -alter

The above instructions should do it and when you are done you can revert the environment to production

export NODE_ENV=production

Then go back to running your app as you normally do.

Upvotes: 0

Jordi
Jordi

Reputation: 331

As I've readed in StackOverflow and other sites including Sails official documentation you have to edit your database by hand to addapt to your new model changes given:

"All of your models' migration settings are forced to migrate: 'safe'. This is a failsafe to protect against inadvertently damaging your production data during deployment." from here in Sails Official Documentation.

Upvotes: 2

Related Questions