Taras Ilyin
Taras Ilyin

Reputation: 23

Sails.js (waterline mysql) global migrate property

I want to know if this is possible to set the "migrate" property globally for all sails (waterline) models?

Directly in concrete model I able to do it so:

module.exports = {
    schema: true,
    migrate: 'safe',   // <-- safe, drop or alter
    autoCreatedAt: true,
    autoUpdatedAt: true,
    autoPK: true,
    attributes: {
      ...
    }
}

But I wondering is there a way to switch the migrate mode globally in app (for all models. I have read the docs, and google it, but didn't found the answer on my question.

Thanks a lot in advance!

Upvotes: 2

Views: 2347

Answers (1)

sgress454
sgress454

Reputation: 24948

If you're using v0.10.x, the answer is yes--you can set model-wide configurations using sails.config.models. By default, your app will come with a config/model.js file, where you can add global model configs:

module.exports.models = {
   connection: 'localDiskDb',
   migrate: 'safe',
   ...etc...
}

I'm not aware of any way to do this in v0.9.x. You can update to v0.10.x (currently in beta) with npm install sails@beta.

Upvotes: 5

Related Questions