Skip to content

queryInterface.addColumn with references not add reference in mysql #5592

@ningshen

Description

@ningshen

queryInterface.addColumn with references not work in mysql

queryInterface.addColumn('Contents', 'ToolId',  {
    type: Sequelize.INTEGER, 
    references: {
        model: 'Tools', 
        key: 'id'
    }
})

will result sql

ALTER TABLE `Contents` ADD `ToolId` INTEGER REFERENCES `Tools` (`id`);

this sql statement is not work.
mysql alter column

add column sql with reference should be:

ALTER TABLE `Contents` ADD `ToolId` INTEGER, ADD FOREIGN KEY (`ToolId`) REFERENCES `Tools` (`id`);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions