Skip to main content

UNIQUE

Constant UNIQUE 

Source
pub const UNIQUE: ColumnMarker;
Expand description

Adds a UNIQUE constraint to a column, table, or index.

ยงExamples

#[column(UNIQUE)]
email: String,

#[PostgresTable(UNIQUE(columns(email, tenant_id), deferrable))]
struct Users {
    email: String,
    tenant_id: i32,
}

#[PostgresIndex(unique)]
struct UsersEmailIdx(Users::email);

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