You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want Sequelize to correctly set ON DELETE CASCADE rules on ArticlePrice table so that I can delete PriceList items without triggering a constraint failure.
What is actually happening?
Sequelize DROPs and CREATEs the tables multple times during synchronization, but strangely forgets ON DELETE CASCADE when creating the table the last time, which makes SQLite throw a constraint failure when truncating the PriceList table.
This only happens if alter: true is set when calling sequelize.sync() AND timestamps: true is set on the sequelize instance. Set either of them to false and the bug doesn't appear.
The bug reappears if I add any additional columns to ArticlePrice, which probably explains that timestamps affects it as well.
Environment
Sequelize version: 6.15.0
Node.js version: v16.13.2
Bug Report Checklist
How does this problem relate to dialects?
I think this problem happens regardless of the dialect.
I think this problem happens only for the following dialect(s):
I don't know, I was using SQLite, with connector library version 4.2.0 and database version 4.2.0
Would you be willing to resolve this issue by submitting a Pull Request?
Yes, I have the time and I know how to start.
Yes, I have the time but I don't know how to start, I would need guidance.
No, I don't have the time, although I believe I could do it if I had the time...
No, I don't have the time and I wouldn't even know how to start.
The text was updated successfully, but these errors were encountered:
Issue Creation Checklist
[x] I have read the contribution guidelines
Bug Description
SSCCE
Here is the link to the SSCCE for this issue: https://github.com/LubosD/sequelize-sscce/blob/master/src/sscce.js
What do you expect to happen?
I want Sequelize to correctly set ON DELETE CASCADE rules on ArticlePrice table so that I can delete PriceList items without triggering a constraint failure.
What is actually happening?
Sequelize DROPs and CREATEs the tables multple times during synchronization, but strangely forgets ON DELETE CASCADE when creating the table the last time, which makes SQLite throw a constraint failure when truncating the PriceList table.
Additional context
This only happens if
alter: true
is set when callingsequelize.sync()
ANDtimestamps: true
is set on the sequelize instance. Set either of them to false and the bug doesn't appear.The bug reappears if I add any additional columns to ArticlePrice, which probably explains that
timestamps
affects it as well.Environment
Bug Report Checklist
How does this problem relate to dialects?
Would you be willing to resolve this issue by submitting a Pull Request?
The text was updated successfully, but these errors were encountered: