Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop the auto migration of the schema in the sails.js

In sails.js, how can we stop the automigration of the schema into the database. Sometimes,it gives error due to the migration. Is there a way that we can make the migration run only when the application is deployed?

like image 761
Luja Shrestha Avatar asked Dec 10 '13 09:12

Luja Shrestha


3 Answers

For all models you can change in confing/models.js

migrate: 'safe',
like image 192
Sergiy Voytovych Avatar answered Oct 19 '22 16:10

Sergiy Voytovych


You can also try something like this:

module.exports = {

  // migrate: 'alter', // adds and/or removes columns on changes to the schema 

  // migrate: 'drop', // drops all your tables and then re-creates them. All data is deleted.

  // migrate: 'safe', doesn't do anything on sails lift- for use in production.

  attributes: { /* ... */ }

};
like image 30
JohnGalt Avatar answered Oct 19 '22 14:10

JohnGalt


We can achieve that by specifying the migrate property in the model. Its default value is alter which attempt to auto-migrate the schema on every alteration.

module.exports = {
  schema: true,
  migrate: 'safe',
  adapter: 'mysql',

  attributes: {}
}
like image 4
Luja Shrestha Avatar answered Oct 19 '22 14:10

Luja Shrestha