sequelize/sequelize — pull request #1294 by janmeier (2014-01-25 16:51:08+00:00)
Title: Change the way PKs for through table are handled

First pass (second actually) at fixing #1117, making the logic surrounding foreign key for through models more reasonable.

This commit adds an `_autoGenerated` property to the id column, if it is added by sequelize. Sequelize will then only remove the primary key from the through models if it has `_autoGenerated` set to true.

One thing that is needed is to add a uniqueness constraint of the foreign keys of the two join tables. If the primary key is removed there's no problem, since we can just do

```sql
PRIMARY KEY(taskId, userId)
```

But if we keep the user defined primary key we would like to do:

```sql
PRIMARY KEY(userTasksId)
UNIQUE (taskId, userId)
``'

The composite unique key part is not supported currently, so I think this should not be merged before we have something like #1024 implemented