sql server – Node.js Sequelize: Error in migration with foreign key

I have an existing SQL Server database where I have to create a new table.

Existing Image table has column as shown in image:

enter image description here

I’m creating a new table using migration with a column referencing to this Image table.

My Query is

module.exports = {
  up: async (queryInterface, Sequelize) => {
    await queryInterface.createTable('NewTable', {
      IdNewTable: {
        primaryKey: true,
        type: Sequelize.INTEGER,
        autoIncrement: true,
        allowNull: false
      IdImage: {
        type: Sequelize.UUID,
        references: {
          model: 'Image',
          key: 'IdImage',
  down: async (queryInterface, Sequelize) => {
    await queryInterface.dropTable('NewTable');

While running a migration, I’m getting this error

ERROR: Could not create constraint or index. See previous errors.

Can someone please help me in this?

Read more here: Source link