Ulises Vargas De Sousa
Ulises Vargas De Sousa

Reputation: 847

Node.js: Defining Postgres Schemas in Sequelize

The Official Documentation doesn't explains clearly how define schemas for database by themselves. I'm assuming that Sequelize is more related to MySql than Postgres (where schemas are mandatory).

If I've already created some schemas in Postgres, how I could sync them with Sequelize?

Upvotes: 3

Views: 9328

Answers (1)

BrTkCa
BrTkCa

Reputation: 4783

You can set the model with the schema using model.schema, something like:

var City = sequelize.define('City', {
    id: {
        type: sequelize.Sequelize.INTEGER,
        primaryKey: true,
        autoIncrement: true,
        field: 'id'
    },
    name: {
        type: sequelize.Sequelize.STRING,
        field: 'name'   
    }
  }, {
    timestamps: false,
    tableName: 'cities'
    });
City.schema("public");

Upvotes: 4

Related Questions