Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Creating children records with transactions locking tables / failing #4745
I am a bit going out of my mind now. I've tried various implementations to try and tackle the problem, but with no success. I am currently running version 3.12.2 of Sequelize.
My problem is the following:
I am trying to create one record and then children records that belong to the created record by using transactions. I have a Document model which has many Revisions. The code for the transaction currently looks like this:
I am not sure if I made any progress with any of the implementations I used. Sometimes I would get an error stating that the table was locked. And other times it will just generate a SELECT query for the revisions table.
Here are my model definitions:
These are the queries being generated:
Thank you in advance!
It looks like the Unique constraint in the Revision model is the problem.
It tries to select before inserting the next record.