nielsgl/sequelize-paper-trail

User Tracking does not populate associated column

mrstebo opened this issue · 1 comments

I have enabled user tracking by following the instructions on the readme. However, when we read Revision.build it does not populate the associated column.

So if I pass the userId to the sequelize options when adding or updating a model I get the following SQL:

Executing (default): INSERT INTO `revisions` (`model`,`document`,`operation`,`document_id`,`revision`,`id`,`created_at`,`updated_at`) VALUES (?,?,?,?,?,?,?,?);

I am having the same issue, after looking into the source code, I found out that defineModels is missing the userModelAttribute definition. After adding

if (options.userModel) { attributes[options.userModelAttribute] = { type: _sequelize.default.INTEGER, allowNull: false, }; }

it adds the userId fine. I had to manually create the revision tables though, since the migration just did not do the tables by itself, had to add the userId column manually as well.