pub struct ForeignKeyDef {
pub ref_table: TableName,
pub ref_columns: Vec<ColumnName>,
pub on_delete: Option<ReferenceAction>,
pub on_update: Option<ReferenceAction>,
pub orphan_strategy: ForeignKeyOrphanStrategy,
}Expand description
Full foreign key definition used in the normalized table representation.
Specifies the referenced table and columns along with optional referential actions for
ON DELETE and ON UPDATE. This is the canonical form produced after parsing any of the
three ForeignKeySyntax variants.
Always add "index": true on the column carrying the foreign key for query performance.
Fields§
§ref_table: TableNameThe table being referenced (the “parent” side of the relationship).
ref_columns: Vec<ColumnName>The column(s) in the referenced table that this foreign key points to.
on_delete: Option<ReferenceAction>Action to take on child rows when the parent row is deleted.
on_update: Option<ReferenceAction>Action to take on child rows when the referenced column(s) in the parent row are updated.
orphan_strategy: ForeignKeyOrphanStrategyPre-cleanup strategy for orphan child rows when the FK is added to
a populated table. See ForeignKeyOrphanStrategy for semantics;
the canonical default (ForeignKeyOrphanStrategy::NullifyOrphans)
is omitted from the JSON wire format.
Stripped from model.schema.json by the schema generator but
preserved in migration.schema.json.
Trait Implementations§
Source§impl Clone for ForeignKeyDef
impl Clone for ForeignKeyDef
Source§fn clone(&self) -> ForeignKeyDef
fn clone(&self) -> ForeignKeyDef
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ForeignKeyDef
impl Debug for ForeignKeyDef
Source§impl<'de> Deserialize<'de> for ForeignKeyDef
impl<'de> Deserialize<'de> for ForeignKeyDef
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for ForeignKeyDef
Source§impl JsonSchema for ForeignKeyDef
impl JsonSchema for ForeignKeyDef
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for ForeignKeyDef
impl PartialEq for ForeignKeyDef
Source§fn eq(&self, other: &ForeignKeyDef) -> bool
fn eq(&self, other: &ForeignKeyDef) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for ForeignKeyDef
impl Serialize for ForeignKeyDef
impl StructuralPartialEq for ForeignKeyDef
Auto Trait Implementations§
impl Freeze for ForeignKeyDef
impl RefUnwindSafe for ForeignKeyDef
impl Send for ForeignKeyDef
impl Sync for ForeignKeyDef
impl Unpin for ForeignKeyDef
impl UnsafeUnpin for ForeignKeyDef
impl UnwindSafe for ForeignKeyDef
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more