If like me your tired of having to choose a migration method every time you lift your SailsJs project, you can specify a default value which it’ll automatically use.

To do this find the config/models.js file, and add the following:

module.exports.models = {
  migrate: 'alter' // Other available options are 'safe' or 'drop'

SailsJs default migration method

Choosing a database migration method in SailsJs

Available Migration Options

  • Safe – Will not attempt to migrate your database allowing you to update it manually.
  • Alter – Will keep existing data and try to ‘automagically’ merge with new data
  • Drop – Will destroy all existing data.

Obviously if your working locally then choose the best option suited for your project. SailsJs will not attempt to run any migration option (even if one is specified) when being run in a production environment.