[Migrations] UNIQUE constraint in Postgres doesn't get removed
See original GitHub issueHi! Coming from RoR world, I love this tool!
I ran into a issue, though, with undoing a migration.
when using the Postgres dialect, migrations that want to remove a UNIQUE constraint from a column in fact does not remove it.
Specifically, after one runs the following up()
function where ‘MyTable’ already exists and has a ‘my_attr’ column:
up: function (queryInterface, Sequelize) {
return queryInterface.changeColumn('MyTable', 'my_attr', {
allowNull: true,
unique: false,
type: Sequelize.STRING
});
}
they will still see UNIQUE CONSTRAINT when running =# \d+ "MyTable"
in psql.
Perusing through the code, it seems as if changeColumnQuery()
in query-generator.js
doesn’t handle removing the unique constraint index at all. It adds it just fine though.
This doesn’t seem like a straightforward fix as you need to first see if an index exists, so I’m documenting the issue… in the hope that someone more familiar with the code to come up with a nice solution 😃
Issue Analytics
- State:
- Created 8 years ago
- Reactions:3
- Comments:15 (1 by maintainers)
Issue on mysql as well
still an issue