How does sails.js handle database migrations when working with a schema database?

I am currently using postgresql for a database.

I come from a more rails background where we create a migration and then run rake db:migrate to transfer the database.

How can I do something like this in sails.js ? I need?

+7
postgresql
source share
1 answer

With the config/models.js file unchanged, each time you sails lift , it will offer you one of three possible options, described in detail in the documents :

  • safe - migrations not performed
  • alter - Sails will try to migrate data as reasonably as possible
  • drop - Sails drop the database and start all migrations. Equivalent to rake db: drop db:migrate

It is recommended to use only safe in the production process and perform manual migration or using one of the following modules (incomplete list):

In development, however, you can usually modify your config/models.js file to set the migrate attribute in the alter setting.

+6
source share

All Articles