Skip to main content

Module attrs

Module attrs 

Source
Expand description

Attribute markers for PostgresTable derive macro.

These const markers are used within #[column(...)] and #[PostgresTable(...)] attributes. Import them from the prelude to get IDE hover documentation.

§Example

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 column type attributes.
ViewMarker
Marker struct for view attributes.

Constants§

AS
Specifies whether a policy is PERMISSIVE or RESTRICTIVE.
AS_CLAUSE
Alias for AS.
BIGINT
Specifies a BIGINT column type (64-bit).
BIGSERIAL
Creates a BIGSERIAL column (auto-incrementing 64-bit integer).
BIT
Specifies a BIT column type.
BIT_VARYING
Alias for VARBIT.
BOOL
Alias for BOOLEAN.
BOOLEAN
Specifies a BOOLEAN column type.
BOX
Specifies a BOX column type.
BYTEA
Specifies a BYTEA column type (binary data).
CASCADE
CASCADE action: Propagate the delete/update to referencing rows.
CHAR
Specifies a CHAR column type.
CHARACTER
Alias for CHAR.
CHARACTER_VARYING
Alias for VARCHAR.
CHECK
Adds a CHECK constraint to a column or table.
CIDR
Specifies a CIDR column type.
CIRCLE
Specifies a CIRCLE column type.
COLLATE
Specifies a collation for a text column.
CONCURRENT
Creates or drops an index CONCURRENTLY.
DATE
Specifies a DATE column type.
DECIMAL
Alias for NUMERIC.
DEFAULT
Specifies a fixed default value for new rows.
DEFAULT_FN
Specifies a function to generate default values at runtime.
DEFAULT_SQL
Specifies a raw SQL default expression emitted directly in DDL.
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
Specifies a 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 IDENTITY column with configurable mode.
INET
Specifies an 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
Specifies an INTEGER column type (32-bit).
INTERVAL
Specifies an INTERVAL column type.
JSON
Enables JSON serialization with JSON type storage.
JSONB
Enables JSON serialization with JSONB storage.
LINE
Specifies a LINE column type.
LSEG
Specifies a LSEG column type.
MACADDR
Specifies a MACADDR column type.
MACADDR8
Specifies a MACADDR8 column type.
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
Specifies a 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
Specifies a PATH column type.
POINT
Specifies a POINT column type.
POLYGON
Specifies a POLYGON column type.
PRIMARY
Marks this column as the PRIMARY KEY.
PRIMARY_KEY
Alias for PRIMARY.
REAL
Specifies a REAL column type (32-bit float).
REFERENCES
Establishes a foreign key reference to another table’s column.
RELATION
Sets the reverse relation accessor name on the referenced table.
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
Specifies a 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
Specifies a TEXT column type.
TIME
Specifies a TIME column type (without timezone).
TIMESTAMP
Specifies a TIMESTAMP column type (without timezone).
TIMESTAMPTZ
Specifies a TIMESTAMPTZ column type (with timezone).
TIMESTAMP_WITHOUT_TIME_ZONE
Alias for TIMESTAMP.
TIMESTAMP_WITH_TIME_ZONE
Alias for TIMESTAMPTZ.
TIMETZ
Specifies a 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
Specifies a UUID column type.
VARBIT
Specifies a VARBIT column type.
VARCHAR
Specifies a VARCHAR column type.
WHERE
Specifies a partial-index predicate.
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).