-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
ON DELETE constraint should default to CASCADE if foreignKey has allowNull: false #2831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
type: bug
DEPRECATED: replace with the "bug" issue type
Comments
A big +1 to this. This also took me a half day to figure out. I might also be nice to have more options available to |
+1. |
I'm using Sequelize 3.13 with PostgreSQL 9.4 var Foo = sequelize.define('Foo', {});
var Bar = sequelize.define('Bar', {});
Bar.belongsTo(Foo, {
foreignKey: { allowNull: false },
}); but |
mine is not working yet... |
Closed
7 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Will fail on MySQL (haven't tested others so far) because the cascade defaults to SET NULL which "obviously" (took me a while to figure it out) obviously doesn't work well with a field that can't be NULL'ed.
Sequelize should check the foreignkey attribute definition, and if allowNull is false it should perhaps either use CASCADE by default or turn off constraints.
The text was updated successfully, but these errors were encountered: