title: Work around Sequelize’s unique constraints in belongsToMany associations
body: <p>I'm using Sequelize in my project. These are the two models:</p>
  
  <pre><code>const User = db.define('user', {
    name: Sequelize.STRING,
    password: Sequelize.STRING
  })
  const Product = db.define('product', {
    name: Sequelize.STRING,
    price: Sequelize.INTEGER
  })
  </code></pre>
  
  <p>Now users can purchase products and I have associations setup like below:</p>
  
  <pre><code>Product.belongsToMany(User, {through: 'UserProducts'})
  User.belongsToMany(Product, {through: 'UserProducts'})
  </code></pre>
  
  <p>I also have this UserProducts table with an additional column.</p>
  
  <pre><code>const UserProducts = db.define('UserProducts', {
    status: Sequelize.STRING
  })
  </code></pre>
  
  <p>Sequelize creates a composite key with combination of userId and productId and will only allow one record with a combination of userId and productId. So, for example, userId 2 and productId 14. </p>
  
  <p>This is a problem for me because sometimes people want to purchase multiple times. I need one of the following scenarios to work:</p>
  
  <ol>
  <li><p>Don't use the composite key and instead have a completely new auto-increment column used as key in UserProducts.</p></li>
  <li><p>Instead of making key with userId and productId alone, allow me to add one more column into the key such as the <code>status</code> so that unique key is a combination of the three.</p></li>
  </ol>
  
  <p>I do want to use the associations as they provide many powerful methods, but want to alter the unique key to work in such a way that I can add multiple rows with the same combination of user id and product id.</p>
  
  <p>And since my models/database is already running, I will need to make use of migrations to make this change.</p>
  
  <p>Any help around this is highly appreciated.</p>