#7702·sequelize

Question about how to modify table schema

Author: johhansantanaCreated May 28, 2017Updated Sep 2, 2026
Labelsdocsstatus: wip

Hello

I have a question on what's the easiest way to modify a table schema

for example, I did User.sync() for the following code

javascript
const User = conn.define('user', {
  name: {
    type: Sequelize.STRING,
    allowNull: false
  },
  lastName: {
    type: Sequelize.STRING,
    allowNull: false
  },
  email: {
    type: Sequelize.STRING,
    allowNull: false,
    validate: {
      isEmail: true
    }
  },
  password: {
    type: Sequelize.STRING,
    allowNull: false
  }
});

if I wanted to add a column, let say, phoneNumber and try to run User.sync() again, it will not add the column there.

If I do User.sync({force: true}) then it will drop the table then create the column (what I want but without dropping the data/table).

Is there a way to do this?