ON_DELETE

Constant ON_DELETE 

Source
pub const ON_DELETE: ColumnMarker;
Expand description

Specifies the ON DELETE action for foreign key references.

§Example

#[column(REFERENCES = User::id, ON_DELETE = CASCADE)]
user_id: i32,

§Supported Actions

  • CASCADE: Delete rows that reference the deleted row
  • SET_NULL: Set the column to NULL when referenced row is deleted
  • SET_DEFAULT: Set the column to its default value
  • RESTRICT: Prevent deletion if referenced
  • NO_ACTION: Similar to RESTRICT (default)

See: https://www.postgresql.org/docs/current/ddl-constraints.html#DDL-CONSTRAINTS-FK