1// adding constraint while table creation
2queryInterface.createTable('Posts', {
3 title: {
4 type: Sequelize.STRING(200),
5 }
6}, {
7 uniqueKeys: {
8 Items_unique: {
9 fields: ['title']
10 }
11 }
12});
13
14// add constraint only
15queryInterface.addConstraint('Posts', ['title'], {
16 type: 'unique',
17 name: 'unique_constraint_name'
18});