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
Currently there's not a way to set up ON DELETE options when setting up reference columns (foreign keys).
Specifically, ON DELETE CASCADE can be an extremely powerful tool for powering scenarios such as right to be forgotten requests. While setting this up can be accomplished through raw sql migrations, it would be ideal to have this as a setting on the reference itself.
The text was updated successfully, but these errors were encountered:
)
Add support for setting the `ON DELETE` behaviour of a foreign key
constraint.
An example migration that uses the behaviour is:
```json
{
"name": "21_add_foreign_key_constraint",
"operations": [
{
"alter_column": {
"table": "posts",
"column": "user_id",
"references": {
"name": "fk_users_id",
"table": "users",
"column": "id",
"on_delete": "CASCADE"
},
"up": "(SELECT CASE WHEN EXISTS (SELECT 1 FROM users WHERE users.id = user_id) THEN user_id ELSE NULL END)",
"down": "user_id"
}
}
]
}
```
The valid options for `on_delete` are `CASCADE`, `SET NULL`, `RESTRICT`,
or `NO ACTION`. If the field is omitted, the default is `NO ACTION`,
Fixes#221
Currently there's not a way to set up ON DELETE options when setting up reference columns (foreign keys).
Specifically, ON DELETE CASCADE can be an extremely powerful tool for powering scenarios such as right to be forgotten requests. While setting this up can be accomplished through raw sql migrations, it would be ideal to have this as a setting on the reference itself.
The text was updated successfully, but these errors were encountered: