Skip to content

Instantly share code, notes, and snippets.

@markdboyd
Last active December 29, 2021 14:12
Show Gist options
  • Save markdboyd/2e6b8ff828a8a9d05e85 to your computer and use it in GitHub Desktop.
Save markdboyd/2e6b8ff828a8a9d05e85 to your computer and use it in GitHub Desktop.
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',
indicesType: 'UNIQUE'
});
@uzair004
Copy link

above raw query worked for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment