0

Is there any way in Sequelize to add another column and then populate it with the contents of another column(s)?

Fabio Espinosa
  • 880
  • 6
  • 14

1 Answers1

1

You can do this using migrations.

Something like

queryInterface.addColumn(
  'MyAwesomeTable',
  'myAwesomeColumn',
  {
    type: Sequelize.STRING,
    default: 6
  }
).then(() => {

   return queryInterface.sequelize.query('UPDATE MyAwesomeTable SET myAwesomeColumn = someOtherColumn')
})
Shivam
  • 3,462
  • 1
  • 15
  • 20