Skip to content

Instantly share code, notes, and snippets.

@markdboyd
markdboyd / migration.js
Last active December 29, 2021 14:12
Drop constraint from Sequelize model
// Remove constraint and index
queryInterface.sequelize.query(
'ALTER TABLE "project" DROP CONSTRAINT IF EXISTS project_name_key;'
).then(function() {
return queryInterface.removeIndex('project', 'project_name_key');
});
// Add unique constraint and index
queryInterface.addIndex('project', ['name'], {
indexName: 'project_name_key',