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

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

See: https://sqlite.org/foreignkeys.html#fk_composite