5

I'm trying to figure out how to disable automatic database migrations for Models in Sails.js.

I know you can set migrate: 'safe' in the model, but is there a way to specify this for all models?

Shaheen Ghiassy
  • 7,397
  • 3
  • 40
  • 40
  • Hi Shaheen, there's not a way to do this right now, but I would suggest adding a feature request for this here: https://trello.com/b/cGzNVE0b/sails-js-feature-requests – JohnGalt Jan 13 '14 at 17:49

1 Answers1

12

Actually, there is a way to do it. ORM hooks are getting defaults from sails.config.model, so all you have to do is to create config/model.js with the following content:

module.exports.model = {
  migrate: 'safe'
}

After this the migrations won't be running upon sails lift, but they will still be applied once you create a document, for example.

bredikhin
  • 8,875
  • 3
  • 40
  • 44
  • Can we use `migrate` setting on per-model basis? – sasha.sochka Feb 28 '15 at 20:54
  • @sasha.sochka yeah, if you follow the link in the answer, you'll see that model properties override the defaults, so using `migrate` on per-model basis should work perfectly. – bredikhin Mar 01 '15 at 00:38