Skip to main content

Module attrs

Module attrs 

Source
Expand description

Names accepted inside #[PostgresTable(...)], #[column(...)], #[PostgresView(...)], #[PostgresIndex(...)] and #[PostgresPolicy(...)].

The macros read these attributes by name, in any letter case; the constants here exist so your editor can show their documentation on hover. Import them through the prelude.

§Examples

fn main() {
use drizzle::postgres::prelude::*;

#[PostgresTable(
    NAME = "users",
    UNLOGGED,
    RLS,
    UNIQUE(columns(email, tenant_id)),
    CHECK(name = "users_score_check", expr = "score >= 0")
)]
struct User {
    #[column(PRIMARY, SERIAL)]
    id: i32,
    #[column(UNIQUE)]
    email: String,
    tenant_id: i32,
    score: i32,
    metadata: String,
}
}

Structs§

ColumnMarker
Marker struct for column constraint attributes.
IndexMarker
Marker struct for index attributes.
NameMarker
Marker struct for the NAME attribute.
PolicyMarker
Marker struct for row-level security policy attributes.
TableMarker
Marker struct for table-level attributes.
TypeMarker
Marker struct for PostgreSQL column type names.
ViewMarker
Marker struct for view attributes.

Constants§

AS
Specifies whether a policy is PERMISSIVE or RESTRICTIVE.
AS_CLAUSE
Alias for AS.
BIGINT
The BIGINT column type (64-bit).
BIGSERIAL
Creates a BIGSERIAL column (auto-incrementing 64-bit integer).
BIT
The BIT column type.
BIT_VARYING
Alias for VARBIT.
BOOL
Alias for BOOLEAN.
BOOLEAN
The BOOLEAN column type.
BOX
The BOX column type.
BYTEA
The BYTEA column type (binary data).
CASCADE
CASCADE action: Propagate the delete/update to referencing rows.
CHAR
The CHAR column type.
CHARACTER
Another name for CHAR; write CHAR(n) in #[column(...)].
CHARACTER_VARYING
Another name for VARCHAR; write VARCHAR(n) in #[column(...)].
CHECK
Adds a CHECK constraint to a column or table.
CIDR
The CIDR column type.
CIRCLE
The CIRCLE column type.
COLLATE
Specifies a collation for a text column.
CONCURRENT
Creates or drops an index CONCURRENTLY.
DATE
The DATE column type.
DECIMAL
Alias for NUMERIC.
DEFAULT
Specifies a database DEFAULT clause for new rows.
DEFAULT_FN
Specifies a function to generate default values at runtime.
DEFERRABLE
Marks a foreign key or table-level UNIQUE constraint as DEFERRABLE.
DEFINITION
Specifies a view definition SQL string or expression.
DOUBLE
Alias for DOUBLE PRECISION.
DOUBLE_PRECISION
The DOUBLE PRECISION column type (64-bit float).
ENUM
Marks this column as storing an enum type.
EXISTING
Marks the view as existing (skip creation).
FLOAT4
Alias for REAL.
FLOAT8
Alias for DOUBLE PRECISION.
FOR
Specifies the command a policy applies to.
FOREIGN_KEY
Adds a table-level composite foreign key constraint.
FOR_CLAUSE
Alias for FOR.
GENERATED
Marks a column as a GENERATED AS (expression) column.
IDENTITY
Creates a GENERATED ... AS IDENTITY column.
INET
The INET column type.
INHERITS
Specifies inheritance from a parent table.
INITIALLY_DEFERRED
Marks a foreign key or table-level UNIQUE constraint as DEFERRABLE INITIALLY DEFERRED.
INT
Alias for INTEGER.
INT2
Alias for SMALLINT.
INT4
Alias for INTEGER.
INT8
Alias for BIGINT.
INTEGER
The INTEGER column type (32-bit).
INTERVAL
The INTERVAL column type.
JSON
Enables JSON serialization with JSON type storage.
JSONB
Enables JSON serialization with JSONB storage.
LINE
The LINE column type.
LSEG
The LSEG column type.
MACADDR
The MACADDR column type.
MACADDR8
The MACADDR8 column type.
MANY_TO_MANY
Names the many-to-many accessor the referenced table gets through this link table.
MATERIALIZED
Marks the view as materialized.
METHOD
Specifies the index access method.
NAME
Specifies a custom name in the database.
NO_ACTION
NO ACTION action: Similar to RESTRICT (default behavior).
NUMERIC
The NUMERIC column type (arbitrary precision).
ON_DELETE
Specifies the ON DELETE action for foreign key references.
ON_UPDATE
Specifies the ON UPDATE action for foreign key references.
PATH
The PATH column type.
POINT
The POINT column type.
POLYGON
The POLYGON column type.
PRIMARY
Marks this column as the PRIMARY KEY.
PRIMARY_KEY
Alias for PRIMARY.
REAL
The REAL column type (32-bit float).
REFERENCES
Establishes a foreign key reference to another table’s column.
RELATION
Names the accessor that loads this table’s rows from the referenced table (the reverse relation).
RESTRICT
RESTRICT action: Prevent delete/update if referenced.
RLS
Enables row-level security for the table.
SCHEMA
Specifies a table or view schema name.
SERIAL
Creates a SERIAL column (auto-incrementing 32-bit integer).
SET_DEFAULT
SET DEFAULT action: Set referencing columns to their default values.
SET_NULL
SET NULL action: Set referencing columns to NULL.
SMALLINT
The SMALLINT column type (16-bit).
SMALLSERIAL
Creates a SMALLSERIAL column (auto-incrementing 16-bit integer).
TABLESPACE
Specifies a tablespace for the table.
TEMPORARY
Creates a TEMPORARY table.
TEXT
The TEXT column type.
TIME
The TIME column type (without timezone).
TIMESTAMP
The TIMESTAMP column type (without timezone).
TIMESTAMPTZ
The TIMESTAMPTZ column type (with timezone).
TIMESTAMP_WITHOUT_TIME_ZONE
Alias for TIMESTAMP.
TIMESTAMP_WITH_TIME_ZONE
Alias for TIMESTAMPTZ.
TIMETZ
The TIMETZ column type (with timezone).
TIME_WITHOUT_TIME_ZONE
Alias for TIME.
TIME_WITH_TIME_ZONE
Alias for TIMETZ.
TO
Specifies roles the policy applies to.
UNIQUE
Adds a UNIQUE constraint to a column, table, or index.
UNLOGGED
Creates an UNLOGGED table.
USING
Specifies a USING clause for materialized views or row-level security policies.
UUID
The UUID column type.
VARBIT
The VARBIT column type.
VARCHAR
The VARCHAR column type.
WHERE
Specifies a partial-index predicate as raw PostgreSQL SQL.
WITH
Sets WITH options for a view definition.
WITH_CHECK
Specifies a WITH CHECK expression for INSERT/UPDATE policies.
WITH_NO_DATA
Create a materialized view WITH NO DATA.
WITH_OPTIONS
Alias for WITH.

Type Aliases§

ReferentialAction
Type alias for referential action markers (uses ColumnMarker for macro compatibility).