1
votes

I am trying to add a column using sequelize-cli migration (http://docs.sequelizejs.com/manual/tutorial/migrations.html). This is the structure -config/config.json -migrations -models -models/index.js

I am trying to run a migration script which is as follows:

'use strict';

module.exports = {

  up: function(queryInterface, Sequelize) {

    return queryInterface.addColumn('faltus','HelpFlag',Sequelize.INTEGER)

  },

  down: function(queryInterface, Sequelize) {

    return queryInterface.removeColumn('faltus','HelpFlag')

  }

};

I am running the script using 'sequelize db:migrate' command. On terminal, the migartion script is successful. MigrationsuccessImage

But when I check the new column in my postgres database, I can't see any 'HelpFlag' column. I tried to rerun the same script by removing the entry in sequelize-meta.json (store all the migartions). I get error: column "HelpFlag" of relation "faltus" already exists.

1
have you checked that you're connected to the same DB ? Your query should be ...addColumn('faltus', 'HelpFlag', {type: Sequelize.Integer}) . Third parameter is an object: docs.sequelizejs.com/class/lib/…Pat-rice
Thank you so much.V.V
Could you please accept my answer then :)Pat-rice
Answer accepted.V.V

1 Answers

1
votes

Your query should be ...addColumn('faltus', 'HelpFlag', {type: Sequelize.Integer}) . Third parameter is an object