Skip to content

Unnecessary changeColumn for primary key when type UUID #6

@krumka

Description

@krumka

Hi !

I have a problem when generating migrations with models of wich the id is an UUID type

On every migration it will add a changeColumn on the column id but she never changes. (the line is generated if a change is made on the specific table)

For example I have plenty of models, all with an UUID as an id column. I change the table named product by only removing a 'type' column and here is the code of the generated migration:

module.exports = {
  up: async (queryInterface, Sequelize) => {
    await queryInterface.sequelize.transaction(async (transaction) => {
      await queryInterface.changeColumn('products', 'id',{'type':Sequelize.DataTypes.UUID,'allowNull':false,'primaryKey':true}, {transaction});
      await queryInterface.removeColumn('products', 'type', {transaction});
    });
  },down: async (queryInterface, Sequelize) => {
    await queryInterface.sequelize.transaction(async (transaction) => {
      await queryInterface.changeColumn('products', 'id',{'type':Sequelize.DataTypes.UUID,'allowNull':false,'primaryKey':true}, {transaction});
      await queryInterface.addColumn('products', 'type',{'type':Sequelize.DataTypes.ENUM('A','B')}, {transaction});
    });
  },
};

Not sure of what is the problem.

In any case, thanks for your project that saves me a lot of time !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions