I have a database with the following tables:
CREATE TABLE IF NOT EXISTS `app_user` (
`user_id` INT NOT NULL,
`user_name` VARCHAR(45) NOT NULL,
PRIMARY KEY
Now Sequelize doesn't support composite foreign keys. This creates several problems.
afterSync hook on the model and a function
that adds a FK to the table if it does not exist. Example code.findAll method with include such model, I use the include[].on option of the findAll method. Or if you don't use as many joins as I do, you can use scope when creating an association (see).