How to undo a Migration that has reference (References)?

Asked

Viewed 57 times

0

I have a Migration that adds a reference to a column (foreign key), but at the time I run db:migrate:undo He doesn’t break up the relationship at the bank. After some tests the migrations continue not matching, only now I have the same relationship established N times, as shown in the following picture:

inserir a descrição da imagem aqui

What is the simplest and most direct way to undo this?

Follow the Migration code:

'use strict';

const { NONE } = require("sequelize");

module.exports = {
  up: (queryInterface, Sequelize) => {
    return queryInterface.changeColumn('area_informations', 'information_type_id', {
      type: Sequelize.INTEGER,
      allowNull: false,
      references: {
        key: 'id',
        model: 'information_types'
      }
    });
  },

  down: (queryInterface, Sequelize) => {
    return queryInterface.changeColumn('area_informations', 'information_type_id', {
      type: Sequelize.INTEGER,
      allowNull: false,
      references: NONE
    });    
  }
};

OBS: In the first attempt the method down had no option to references because theoretically it would overwrite right?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.