2

My database is MSSQL.

I have a migration script where I have created the table like this:

module.exports = {
    up: function(queryInterface) {
        return queryInterface.createTable(
            'tablename', {
                'column1': {
                    type: SEQUELIZE.INTEGER,
                    references: {
                        model: 'Foobar',
                        key: 'id',
                        onDelete: 'cascade'
                    }
                }
            }
        }
    }
};

I want to change the reference for this column, so I wrote another migration script:

module.exports = {
    up: function(queryInterface) {
        return queryInterface.changeColumn(
            'tablename', {
                'column1': {
                    type: SEQUELIZE.INTEGER,
                    references: {
                        model: 'BarFoo', //I changed the reference
                        key: 'id',
                        onDelete: 'cascade'
                    }
                }
            }
        }
    }
};

However, on running the migration, I find that the reference is not changed in the database. The column still refers to the old reference - FooBar instead of BarFoo. The migration script ran successfully but the change did not happen. Any idea why?

I run the migrations using sequelize cli - sequelize db:migrate

callmekatootie
  • 10,989
  • 15
  • 69
  • 104

0 Answers0