Sequellize Migration menetapkan kendala unik
// adding constraint while table creation
queryInterface.createTable('Posts', {
title: {
type: Sequelize.STRING(200),
}
}, {
uniqueKeys: {
Items_unique: {
fields: ['title']
}
}
});
// add constraint only
queryInterface.addConstraint('Posts', ['title'], {
type: 'unique',
name: 'unique_constraint_name'
});
Obedient Oyster