Answers for "sequelize migration set unique constraint"

0

sequelize migration set unique constraint

// 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'
});
Posted by: Guest on April-21-2021

Code answers related to "sequelize migration set unique constraint"

Code answers related to "Javascript"

Browse Popular Code Answers by Language