Skip to main content

FOREIGN_KEY

Constant FOREIGN_KEY 

Source
pub const FOREIGN_KEY: TableMarker;
Expand description

Adds a table-level composite foreign key constraint.

ยงExample

#[PostgresTable(FOREIGN_KEY(
    columns(tenant_id, user_id),
    references(Users, tenant_id, id),
    on_delete = "CASCADE",
    deferrable
))]
struct Posts {
    tenant_id: i32,
    user_id: i32,
}

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