Using sails.js with an existing postgres database

前端 未结 1 1343
长情又很酷
长情又很酷 2021-02-19 22:13

I was looking at using Sails for an app that we are developing.

I\'m using the sails-postgresql adapter which uses the waterline orm.

I have an existing database

相关标签:
1条回答
  • 2021-02-19 22:26

    I am the author of Sails-Postgresql. Sails has an ORM called Waterline that it uses for managing data. The default setting assumes that you would want to auto-migrate your database to match your model attributes. Because Postgresql is a SQL database the Sails-Postgresql adapter has a setting called syncable that defaults to true. This would be false in a NoSQL database like redis.

    This is easy to turn off if you want to manage your database columns yourself. You can add migrate: safe to your model and it won't try and update your database schema when you start Sails.

    module.exports = {
      adapter: 'postgresql',
      migrate: 'safe',
      attributes: {
        title: { type: 'string' }
      }
    };
    

    Sails doesn't have anything like migrations in Rails. It uses auto-migrations to attempt to remove this from your development process and then leaves updating your production schema to you.

    0 讨论(0)
提交回复
热议问题