drizzle_postgres/attrs.rs
1//! Attribute markers for `PostgresTable` derive macro.
2//!
3//! These const markers are used within `#[column(...)]` and `#[PostgresTable(...)]`
4//! attributes. Import them from the prelude to get IDE hover documentation.
5//!
6//! # Example
7//! ```rust
8//! # extern crate self as drizzle;
9//! # mod _drizzle {
10//! # pub mod core { pub use drizzle_core::*; }
11//! # pub mod error { pub use drizzle_core::error::*; }
12//! # pub mod types { pub use drizzle_types::*; }
13//! # pub mod migrations { pub use drizzle_migrations::*; }
14//! # pub use drizzle_types::Dialect;
15//! # pub use drizzle_types as ddl;
16//! # pub mod postgres {
17//! # pub mod values { pub use drizzle_postgres::values::*; }
18//! # pub mod traits { pub use drizzle_postgres::traits::*; }
19//! # pub mod common { pub use drizzle_postgres::common::*; }
20//! # pub mod attrs { pub use drizzle_postgres::attrs::*; }
21//! # pub mod builder { pub use drizzle_postgres::builder::*; }
22//! # pub mod helpers { pub use drizzle_postgres::helpers::*; }
23//! # pub mod expr { pub use drizzle_postgres::expr::*; }
24//! # pub mod types { pub use drizzle_postgres::types::*; }
25//! # pub struct Row;
26//! # impl Row {
27//! # pub fn get<'a, I, T>(&'a self, _: I) -> T { unimplemented!() }
28//! # pub fn try_get<'a, I, T>(&'a self, _: I) -> Result<T, Box<dyn std::error::Error + Sync + Send>> { unimplemented!() }
29//! # }
30//! # pub mod prelude {
31//! # pub use drizzle_macros::{PostgresTable, PostgresSchema, PostgresIndex};
32//! # pub use drizzle_postgres::attrs::*;
33//! # pub use drizzle_postgres::common::PostgresSchemaType;
34//! # pub use drizzle_postgres::traits::{PostgresColumn, PostgresTable};
35//! # pub use drizzle_postgres::values::{PostgresInsertValue, PostgresUpdateValue, PostgresValue};
36//! # pub use drizzle_core::*;
37//! # }
38//! # }
39//! # }
40//! # pub use _drizzle::*;
41//! # pub use const_format;
42//! fn main() {
43//! use drizzle::postgres::prelude::*;
44//!
45//! #[PostgresTable(NAME = "users")]
46//! struct User {
47//! #[column(PRIMARY, SERIAL)]
48//! id: i32,
49//! #[column(UNIQUE)]
50//! email: String,
51//! metadata: String,
52//! }
53//! }
54//! ```
55
56/// Marker struct for column constraint attributes.
57#[derive(Debug, Clone, Copy)]
58pub struct ColumnMarker;
59
60//------------------------------------------------------------------------------
61// Primary Key Constraints
62//------------------------------------------------------------------------------
63
64/// Marks this column as the PRIMARY KEY.
65///
66/// ## Example
67/// ```rust
68/// # let _ = r####"
69/// #[column(PRIMARY)]
70/// id: i32,
71/// # "####;
72/// ```
73///
74/// See: <https://www.postgresql.org/docs/current/ddl-constraints.html#DDL-CONSTRAINTS-PRIMARY-KEYS>
75pub const PRIMARY: ColumnMarker = ColumnMarker;
76
77/// Alias for [`PRIMARY`].
78pub const PRIMARY_KEY: ColumnMarker = ColumnMarker;
79
80//------------------------------------------------------------------------------
81// Auto-increment Types
82//------------------------------------------------------------------------------
83
84/// Creates a SERIAL column (auto-incrementing 32-bit integer).
85///
86/// ## Example
87/// ```rust
88/// # let _ = r####"
89/// #[column(PRIMARY, SERIAL)]
90/// id: i32,
91/// # "####;
92/// ```
93///
94/// See: <https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-SERIAL>
95pub const SERIAL: ColumnMarker = ColumnMarker;
96
97/// Creates a BIGSERIAL column (auto-incrementing 64-bit integer).
98///
99/// ## Example
100/// ```rust
101/// # let _ = r####"
102/// #[column(PRIMARY, BIGSERIAL)]
103/// id: i64,
104/// # "####;
105/// ```
106///
107/// See: <https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-SERIAL>
108pub const BIGSERIAL: ColumnMarker = ColumnMarker;
109
110/// Creates a SMALLSERIAL column (auto-incrementing 16-bit integer).
111///
112/// ## Example
113/// ```rust
114/// # let _ = r####"
115/// #[column(PRIMARY, SMALLSERIAL)]
116/// id: i16,
117/// # "####;
118/// ```
119///
120/// See: <https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-SERIAL>
121pub const SMALLSERIAL: ColumnMarker = ColumnMarker;
122
123//------------------------------------------------------------------------------
124// Uniqueness Constraints
125//------------------------------------------------------------------------------
126
127/// Adds a UNIQUE constraint to this column.
128///
129/// ## Example
130/// ```rust
131/// # let _ = r####"
132/// #[column(UNIQUE)]
133/// email: String,
134/// # "####;
135/// ```
136///
137/// See: <https://www.postgresql.org/docs/current/ddl-constraints.html#DDL-CONSTRAINTS-UNIQUE-CONSTRAINTS>
138pub const UNIQUE: ColumnMarker = ColumnMarker;
139
140//------------------------------------------------------------------------------
141// Identity Columns
142//------------------------------------------------------------------------------
143
144/// Creates a GENERATED IDENTITY column with configurable mode.
145///
146/// ## Syntax
147/// - `identity(always)` - User values rejected unless OVERRIDING SYSTEM VALUE
148/// - `identity(by_default)` - User values take precedence
149///
150/// ## Example
151/// ```rust
152/// # let _ = r####"
153/// // GENERATED ALWAYS AS IDENTITY - strictest mode
154/// #[column(identity(always), primary)]
155/// id: i64,
156///
157/// // GENERATED BY DEFAULT AS IDENTITY - allows override
158/// #[column(identity(by_default), primary)]
159/// id: i64,
160/// # "####;
161/// ```
162///
163/// ## Technical Details
164/// `PostgreSQL`'s identity columns are SQL-standard compliant, unlike SERIAL.
165/// Use ALWAYS for auto-generated IDs, BY DEFAULT when you need to occasionally set values.
166///
167/// See: <https://www.postgresql.org/docs/current/ddl-identity-columns.html>
168pub const IDENTITY: ColumnMarker = ColumnMarker;
169
170/// Marks a column as a GENERATED AS (expression) column.
171///
172/// ## Syntax
173/// - `generated(stored, "expression")` - Computed on write, stored on disk
174/// - `generated(virtual, "expression")` - Computed on read, not stored (`PostgreSQL` 17+)
175///
176/// ## Example
177/// ```rust
178/// # let _ = r####"
179/// #[column(generated(stored, "price * quantity"))]
180/// total: i32,
181///
182/// #[column(generated(virtual, "first_name || ' ' || last_name"))]
183/// full_name: String,
184/// # "####;
185/// ```
186///
187/// ## Technical Details
188/// Generated columns cannot be written to directly.
189/// STORED columns are computed and stored on write.
190/// VIRTUAL columns are computed on read (`PostgreSQL` 17+).
191///
192/// See: <https://www.postgresql.org/docs/current/ddl-generated-columns.html>
193pub const GENERATED: ColumnMarker = ColumnMarker;
194
195//------------------------------------------------------------------------------
196// Serialization Modes
197//------------------------------------------------------------------------------
198
199/// Enables JSON serialization with JSON type storage.
200///
201/// ## Example
202/// ```rust
203/// # let _ = r####"
204/// #[column(JSON)]
205/// metadata: UserMetadata,
206/// # "####;
207/// ```
208///
209/// Requires the `serde` feature. The field type must implement `Serialize` and `Deserialize`.
210///
211/// See: <https://www.postgresql.org/docs/current/datatype-json.html>
212pub const JSON: ColumnMarker = ColumnMarker;
213
214/// Enables JSON serialization with JSONB storage.
215///
216/// ## Example
217/// ```rust
218/// # let _ = r####"
219/// #[column(JSONB)]
220/// config: AppConfig,
221/// # "####;
222/// ```
223///
224/// JSONB is the recommended JSON storage format for most use cases.
225/// It supports indexing and efficient querying.
226///
227/// Requires the `serde` feature. The field type must implement `Serialize` and `Deserialize`.
228///
229/// See: <https://www.postgresql.org/docs/current/datatype-json.html>
230pub const JSONB: ColumnMarker = ColumnMarker;
231
232/// Marks this column as storing an enum type.
233///
234/// ## Example
235/// ```rust
236/// # let _ = r####"
237/// #[column(ENUM)]
238/// role: Role,
239/// # "####;
240/// ```
241///
242/// For `PostgreSQL` native ENUM types or text-based enum storage.
243///
244/// See: <https://www.postgresql.org/docs/current/datatype-enum.html>
245pub const ENUM: ColumnMarker = ColumnMarker;
246
247//------------------------------------------------------------------------------
248// Collation Markers
249//------------------------------------------------------------------------------
250
251/// Specifies a collation for a text column.
252///
253/// PostgreSQL collation identifiers are quoted names; the DDL emitter
254/// wraps whatever you supply here in double quotes, so write the bare
255/// name (`"en_US"`, `"C"`, `"POSIX"`, or any `CREATE COLLATION` value).
256///
257/// ## Example
258/// ```rust
259/// # let _ = r####"
260/// #[column(COLLATE = "en_US")]
261/// name: String,
262/// # "####;
263/// ```
264///
265/// See: <https://www.postgresql.org/docs/current/collation.html>
266pub const COLLATE: ColumnMarker = ColumnMarker;
267
268//------------------------------------------------------------------------------
269// Default Value Parameters
270//------------------------------------------------------------------------------
271
272/// Specifies a function to generate default values at runtime.
273///
274/// The function is called for each insert when no value is provided.
275///
276/// ## Example
277/// ```rust
278/// # let _ = r####"
279/// #[column(DEFAULT_FN = Uuid::new_v4)]
280/// id: Uuid,
281/// # "####;
282/// ```
283///
284/// ## Difference from DEFAULT
285/// - `DEFAULT_FN`: Calls the function at runtime for each insert (e.g., UUID generation)
286/// - `DEFAULT`: Uses a fixed compile-time value
287pub const DEFAULT_FN: ColumnMarker = ColumnMarker;
288
289/// Specifies a fixed default value for new rows.
290///
291/// ## Example
292/// ```rust
293/// # let _ = r####"
294/// #[column(DEFAULT = 0)]
295/// count: i32,
296///
297/// #[column(DEFAULT = "guest")]
298/// role: String,
299/// # "####;
300/// ```
301///
302/// For runtime-generated values (UUIDs, timestamps), use [`DEFAULT_FN`] instead.
303///
304/// See: <https://www.postgresql.org/docs/current/ddl-default.html>
305pub const DEFAULT: ColumnMarker = ColumnMarker;
306
307/// Establishes a foreign key reference to another table's column.
308///
309/// ## Example
310/// ```rust
311/// # let _ = r####"
312/// #[column(REFERENCES = User::id)]
313/// user_id: i32,
314/// # "####;
315/// ```
316///
317/// See: <https://www.postgresql.org/docs/current/ddl-constraints.html#DDL-CONSTRAINTS-FK>
318pub const REFERENCES: ColumnMarker = ColumnMarker;
319
320/// Specifies the ON DELETE action for foreign key references.
321///
322/// ## Example
323/// ```rust
324/// # let _ = r####"
325/// #[column(REFERENCES = User::id, ON_DELETE = CASCADE)]
326/// user_id: i32,
327/// # "####;
328/// ```
329///
330/// ## Supported Actions
331/// - `CASCADE`: Delete rows that reference the deleted row
332/// - `SET_NULL`: Set the column to NULL when referenced row is deleted
333/// - `SET_DEFAULT`: Set the column to its default value
334/// - `RESTRICT`: Prevent deletion if referenced
335/// - `NO_ACTION`: Similar to RESTRICT (default)
336///
337/// See: <https://www.postgresql.org/docs/current/ddl-constraints.html#DDL-CONSTRAINTS-FK>
338pub const ON_DELETE: ColumnMarker = ColumnMarker;
339
340/// Specifies the ON UPDATE action for foreign key references.
341///
342/// ## Example
343/// ```rust
344/// # let _ = r####"
345/// #[column(REFERENCES = User::id, ON_UPDATE = CASCADE)]
346/// user_id: i32,
347/// # "####;
348/// ```
349///
350/// ## Supported Actions
351/// - `CASCADE`: Update referencing rows when referenced row is updated
352/// - `SET_NULL`: Set the column to NULL when referenced row is updated
353/// - `SET_DEFAULT`: Set the column to its default value
354/// - `RESTRICT`: Prevent update if referenced
355/// - `NO_ACTION`: Similar to RESTRICT (default)
356///
357/// See: <https://www.postgresql.org/docs/current/ddl-constraints.html#DDL-CONSTRAINTS-FK>
358pub const ON_UPDATE: ColumnMarker = ColumnMarker;
359
360//------------------------------------------------------------------------------
361// Referential Action Values
362//------------------------------------------------------------------------------
363
364/// Type alias for referential action markers (uses `ColumnMarker` for macro compatibility).
365pub type ReferentialAction = ColumnMarker;
366
367/// CASCADE action: Propagate the delete/update to referencing rows.
368///
369/// ## Example
370/// ```rust
371/// # let _ = r####"
372/// #[column(REFERENCES = User::id, ON_DELETE = CASCADE)]
373/// user_id: i32,
374/// # "####;
375/// ```
376///
377/// See: <https://www.postgresql.org/docs/current/ddl-constraints.html#DDL-CONSTRAINTS-FK>
378pub const CASCADE: ColumnMarker = ColumnMarker;
379
380/// SET NULL action: Set referencing columns to NULL.
381///
382/// ## Example
383/// ```rust
384/// # let _ = r####"
385/// #[column(REFERENCES = User::id, ON_DELETE = SET_NULL)]
386/// user_id: Option<i32>,
387/// # "####;
388/// ```
389///
390/// See: <https://www.postgresql.org/docs/current/ddl-constraints.html#DDL-CONSTRAINTS-FK>
391pub const SET_NULL: ColumnMarker = ColumnMarker;
392
393/// SET DEFAULT action: Set referencing columns to their default values.
394///
395/// ## Example
396/// ```rust
397/// # let _ = r####"
398/// #[column(REFERENCES = User::id, ON_DELETE = SET_DEFAULT, DEFAULT = 0)]
399/// user_id: i32,
400/// # "####;
401/// ```
402///
403/// See: <https://www.postgresql.org/docs/current/ddl-constraints.html#DDL-CONSTRAINTS-FK>
404pub const SET_DEFAULT: ColumnMarker = ColumnMarker;
405
406/// RESTRICT action: Prevent delete/update if referenced.
407///
408/// ## Example
409/// ```rust
410/// # let _ = r####"
411/// #[column(REFERENCES = User::id, ON_DELETE = RESTRICT)]
412/// user_id: i32,
413/// # "####;
414/// ```
415///
416/// See: <https://www.postgresql.org/docs/current/ddl-constraints.html#DDL-CONSTRAINTS-FK>
417pub const RESTRICT: ColumnMarker = ColumnMarker;
418
419/// NO ACTION action: Similar to RESTRICT (default behavior).
420///
421/// ## Example
422/// ```rust
423/// # let _ = r####"
424/// #[column(REFERENCES = User::id, ON_DELETE = NO_ACTION)]
425/// user_id: i32,
426/// # "####;
427/// ```
428///
429/// See: <https://www.postgresql.org/docs/current/ddl-constraints.html#DDL-CONSTRAINTS-FK>
430pub const NO_ACTION: ColumnMarker = ColumnMarker;
431
432/// Adds a CHECK constraint to this column.
433///
434/// ## Example
435/// ```rust
436/// # let _ = r####"
437/// #[column(CHECK = "age >= 0")]
438/// age: i32,
439/// # "####;
440/// ```
441///
442/// See: <https://www.postgresql.org/docs/current/ddl-constraints.html#DDL-CONSTRAINTS-CHECK-CONSTRAINTS>
443pub const CHECK: ColumnMarker = ColumnMarker;
444
445//------------------------------------------------------------------------------
446// Name Marker (shared by column and table attributes)
447//------------------------------------------------------------------------------
448
449/// Marker struct for the NAME attribute.
450#[derive(Debug, Clone, Copy)]
451pub struct NameMarker;
452
453/// Specifies a custom name in the database.
454///
455/// By default, table, view, and column names are automatically converted to `snake_case`
456/// from the Rust struct/field name. Use NAME to override this behavior.
457///
458/// ## Column Example
459/// ```rust
460/// # let _ = r####"
461/// // Field `createdAt` becomes `created_at` by default
462/// created_at: DateTime<Utc>,
463///
464/// // Override with custom name:
465/// #[column(NAME = "creation_timestamp")]
466/// created_at: DateTime<Utc>,
467/// # "####;
468/// ```
469///
470/// ## Table Example
471/// ```rust
472/// # let _ = r####"
473/// // Struct `UserAccount` becomes table `user_account` by default
474/// struct UserAccount { ... }
475///
476/// // Override with custom name:
477/// #[PostgresTable(NAME = "user_accounts")]
478/// struct UserAccount { ... }
479/// # "####;
480/// ```
481///
482/// ## View Example
483/// ```rust
484/// # let _ = r####"
485/// #[PostgresView(NAME = "active_users")]
486/// struct ActiveUsers { ... }
487/// # "####;
488/// ```
489pub const NAME: NameMarker = NameMarker;
490
491//------------------------------------------------------------------------------
492// View Attribute Markers
493//------------------------------------------------------------------------------
494
495/// Marker struct for view attributes.
496#[derive(Debug, Clone, Copy)]
497pub struct ViewMarker;
498
499/// Specifies a view definition SQL string or expression.
500///
501/// ## Examples
502/// ```rust
503/// # let _ = r####"
504/// #[PostgresView(DEFINITION = "SELECT id, name FROM users")]
505/// struct UserNames { id: i32, name: String }
506/// # "####;
507/// ```
508///
509/// ```rust
510/// # let _ = r####"
511/// #[PostgresView(
512/// DEFINITION = {
513/// let builder = drizzle::postgres::QueryBuilder::new::<Schema>();
514/// let Schema { user } = Schema::new();
515/// builder.select((user.id, user.name)).from(user)
516/// }
517/// )]
518/// struct UserNames { id: i32, name: String }
519/// # "####;
520/// ```
521pub const DEFINITION: ViewMarker = ViewMarker;
522
523/// Specifies a view schema name.
524///
525/// ## Example
526/// ```rust
527/// # let _ = r####"
528/// #[PostgresView(SCHEMA = "auth")]
529/// struct AuthUsers { ... }
530/// # "####;
531/// ```
532pub const SCHEMA: ViewMarker = ViewMarker;
533
534/// Marks the view as materialized.
535///
536/// ## Example
537/// ```rust
538/// # let _ = r####"
539/// #[PostgresView(MATERIALIZED)]
540/// struct ActiveUsers { ... }
541/// # "####;
542/// ```
543pub const MATERIALIZED: ViewMarker = ViewMarker;
544
545/// Sets WITH options for a view definition.
546///
547/// ## Example
548/// ```rust
549/// # let _ = r####"
550/// #[PostgresView(WITH = ViewWithOptionDef::new().security_barrier())]
551/// struct ActiveUsers { ... }
552/// # "####;
553/// ```
554pub const WITH: ViewMarker = ViewMarker;
555
556/// Alias for [`WITH`].
557pub const WITH_OPTIONS: ViewMarker = ViewMarker;
558
559/// Create a materialized view WITH NO DATA.
560///
561/// ## Example
562/// ```rust
563/// # let _ = r####"
564/// #[PostgresView(MATERIALIZED, WITH_NO_DATA)]
565/// struct ActiveUsers { ... }
566/// # "####;
567/// ```
568pub const WITH_NO_DATA: ViewMarker = ViewMarker;
569
570/// Specifies a USING clause for materialized views.
571///
572/// ## Example
573/// ```rust
574/// # let _ = r####"
575/// #[PostgresView(USING = "heap")]
576/// struct ActiveUsers { ... }
577/// # "####;
578/// ```
579pub const USING: ViewMarker = ViewMarker;
580
581/// Marks the view as existing (skip creation).
582///
583/// ## Example
584/// ```rust
585/// # let _ = r####"
586/// #[PostgresView(EXISTING)]
587/// struct ExistingView { ... }
588/// # "####;
589/// ```
590pub const EXISTING: ViewMarker = ViewMarker;
591
592//------------------------------------------------------------------------------
593// Table Attribute Markers
594//------------------------------------------------------------------------------
595
596/// Marker struct for table-level attributes.
597#[derive(Debug, Clone, Copy)]
598pub struct TableMarker;
599
600/// Creates an UNLOGGED table.
601///
602/// ## Example
603/// ```rust
604/// # mod drizzle {
605/// # pub mod core { pub use drizzle_core::*; }
606/// # pub mod error { pub use drizzle_core::error::*; }
607/// # pub mod types { pub use drizzle_types::*; }
608/// # pub mod migrations { pub use drizzle_migrations::*; }
609/// # pub use drizzle_types::Dialect;
610/// # pub use drizzle_types as ddl;
611/// # pub mod postgres {
612/// # pub mod values { pub use drizzle_postgres::values::*; }
613/// # pub mod traits { pub use drizzle_postgres::traits::*; }
614/// # pub mod common { pub use drizzle_postgres::common::*; }
615/// # pub mod attrs { pub use drizzle_postgres::attrs::*; }
616/// # pub mod builder { pub use drizzle_postgres::builder::*; }
617/// # pub mod helpers { pub use drizzle_postgres::helpers::*; }
618/// # pub mod expr { pub use drizzle_postgres::expr::*; }
619/// # pub mod types { pub use drizzle_postgres::types::*; }
620/// # pub struct Row;
621/// # impl Row {
622/// # pub fn get<'a, I, T>(&'a self, _: I) -> T { unimplemented!() }
623/// # pub fn try_get<'a, I, T>(&'a self, _: I) -> Result<T, Box<dyn std::error::Error + Sync + Send>> { unimplemented!() }
624/// # }
625/// # pub mod prelude {
626/// # pub use drizzle_macros::{PostgresTable, PostgresSchema, PostgresIndex};
627/// # pub use drizzle_postgres::attrs::*;
628/// # pub use drizzle_postgres::common::PostgresSchemaType;
629/// # pub use drizzle_postgres::traits::{PostgresColumn, PostgresTable};
630/// # pub use drizzle_postgres::values::{PostgresInsertValue, PostgresUpdateValue, PostgresValue};
631/// # pub use drizzle_core::*;
632/// # }
633/// # }
634/// # }
635/// use drizzle::postgres::prelude::*;
636///
637/// #[PostgresTable(UNLOGGED)]
638/// struct SessionCache {
639/// #[column(PRIMARY)]
640/// key: String,
641/// data: String,
642/// }
643/// ```
644///
645/// Unlogged tables are faster but data is not crash-safe.
646///
647/// See: <https://www.postgresql.org/docs/current/sql-createtable.html#SQL-CREATETABLE-UNLOGGED>
648pub const UNLOGGED: TableMarker = TableMarker;
649
650/// Creates a TEMPORARY table.
651///
652/// ## Example
653/// ```rust
654/// # mod drizzle {
655/// # pub mod core { pub use drizzle_core::*; }
656/// # pub mod error { pub use drizzle_core::error::*; }
657/// # pub mod types { pub use drizzle_types::*; }
658/// # pub mod migrations { pub use drizzle_migrations::*; }
659/// # pub use drizzle_types::Dialect;
660/// # pub use drizzle_types as ddl;
661/// # pub mod postgres {
662/// # pub mod values { pub use drizzle_postgres::values::*; }
663/// # pub mod traits { pub use drizzle_postgres::traits::*; }
664/// # pub mod common { pub use drizzle_postgres::common::*; }
665/// # pub mod attrs { pub use drizzle_postgres::attrs::*; }
666/// # pub mod builder { pub use drizzle_postgres::builder::*; }
667/// # pub mod helpers { pub use drizzle_postgres::helpers::*; }
668/// # pub mod expr { pub use drizzle_postgres::expr::*; }
669/// # pub mod types { pub use drizzle_postgres::types::*; }
670/// # pub struct Row;
671/// # impl Row {
672/// # pub fn get<'a, I, T>(&'a self, _: I) -> T { unimplemented!() }
673/// # pub fn try_get<'a, I, T>(&'a self, _: I) -> Result<T, Box<dyn std::error::Error + Sync + Send>> { unimplemented!() }
674/// # }
675/// # pub mod prelude {
676/// # pub use drizzle_macros::{PostgresTable, PostgresSchema, PostgresIndex};
677/// # pub use drizzle_postgres::attrs::*;
678/// # pub use drizzle_postgres::common::PostgresSchemaType;
679/// # pub use drizzle_postgres::traits::{PostgresColumn, PostgresTable};
680/// # pub use drizzle_postgres::values::{PostgresInsertValue, PostgresUpdateValue, PostgresValue};
681/// # pub use drizzle_core::*;
682/// # }
683/// # }
684/// # }
685/// use drizzle::postgres::prelude::*;
686///
687/// #[PostgresTable(TEMPORARY)]
688/// struct TempData {
689/// id: i32,
690/// value: String,
691/// }
692/// ```
693///
694/// Temporary tables exist only for the current session.
695///
696/// See: <https://www.postgresql.org/docs/current/sql-createtable.html#SQL-CREATETABLE-TEMPORARY>
697pub const TEMPORARY: TableMarker = TableMarker;
698
699/// Specifies inheritance from a parent table.
700///
701/// ## Example
702/// ```rust
703/// # mod drizzle {
704/// # pub mod core { pub use drizzle_core::*; }
705/// # pub mod error { pub use drizzle_core::error::*; }
706/// # pub mod types { pub use drizzle_types::*; }
707/// # pub mod migrations { pub use drizzle_migrations::*; }
708/// # pub use drizzle_types::Dialect;
709/// # pub use drizzle_types as ddl;
710/// # pub mod postgres {
711/// # pub mod values { pub use drizzle_postgres::values::*; }
712/// # pub mod traits { pub use drizzle_postgres::traits::*; }
713/// # pub mod common { pub use drizzle_postgres::common::*; }
714/// # pub mod attrs { pub use drizzle_postgres::attrs::*; }
715/// # pub mod builder { pub use drizzle_postgres::builder::*; }
716/// # pub mod helpers { pub use drizzle_postgres::helpers::*; }
717/// # pub mod expr { pub use drizzle_postgres::expr::*; }
718/// # pub mod types { pub use drizzle_postgres::types::*; }
719/// # pub struct Row;
720/// # impl Row {
721/// # pub fn get<'a, I, T>(&'a self, _: I) -> T { unimplemented!() }
722/// # pub fn try_get<'a, I, T>(&'a self, _: I) -> Result<T, Box<dyn std::error::Error + Sync + Send>> { unimplemented!() }
723/// # }
724/// # pub mod prelude {
725/// # pub use drizzle_macros::{PostgresTable, PostgresSchema, PostgresIndex};
726/// # pub use drizzle_postgres::attrs::*;
727/// # pub use drizzle_postgres::common::PostgresSchemaType;
728/// # pub use drizzle_postgres::traits::{PostgresColumn, PostgresTable};
729/// # pub use drizzle_postgres::values::{PostgresInsertValue, PostgresUpdateValue, PostgresValue};
730/// # pub use drizzle_core::*;
731/// # }
732/// # }
733/// # }
734/// use drizzle::postgres::prelude::*;
735///
736/// #[PostgresTable(INHERITS = "base_table")]
737/// struct ChildTable {
738/// extra_field: String,
739/// }
740/// ```
741///
742/// See: <https://www.postgresql.org/docs/current/ddl-inherit.html>
743pub const INHERITS: TableMarker = TableMarker;
744
745/// Specifies a tablespace for the table.
746///
747/// ## Example
748/// ```rust
749/// # mod drizzle {
750/// # pub mod core { pub use drizzle_core::*; }
751/// # pub mod error { pub use drizzle_core::error::*; }
752/// # pub mod types { pub use drizzle_types::*; }
753/// # pub mod migrations { pub use drizzle_migrations::*; }
754/// # pub use drizzle_types::Dialect;
755/// # pub use drizzle_types as ddl;
756/// # pub mod postgres {
757/// # pub mod values { pub use drizzle_postgres::values::*; }
758/// # pub mod traits { pub use drizzle_postgres::traits::*; }
759/// # pub mod common { pub use drizzle_postgres::common::*; }
760/// # pub mod attrs { pub use drizzle_postgres::attrs::*; }
761/// # pub mod builder { pub use drizzle_postgres::builder::*; }
762/// # pub mod helpers { pub use drizzle_postgres::helpers::*; }
763/// # pub mod expr { pub use drizzle_postgres::expr::*; }
764/// # pub mod types { pub use drizzle_postgres::types::*; }
765/// # pub struct Row;
766/// # impl Row {
767/// # pub fn get<'a, I, T>(&'a self, _: I) -> T { unimplemented!() }
768/// # pub fn try_get<'a, I, T>(&'a self, _: I) -> Result<T, Box<dyn std::error::Error + Sync + Send>> { unimplemented!() }
769/// # }
770/// # pub mod prelude {
771/// # pub use drizzle_macros::{PostgresTable, PostgresSchema, PostgresIndex};
772/// # pub use drizzle_postgres::attrs::*;
773/// # pub use drizzle_postgres::common::PostgresSchemaType;
774/// # pub use drizzle_postgres::traits::{PostgresColumn, PostgresTable};
775/// # pub use drizzle_postgres::values::{PostgresInsertValue, PostgresUpdateValue, PostgresValue};
776/// # pub use drizzle_core::*;
777/// # }
778/// # }
779/// # }
780/// use drizzle::postgres::prelude::*;
781///
782/// #[PostgresTable(TABLESPACE = "fast_storage")]
783/// struct HighPerfTable {
784/// #[column(PRIMARY)]
785/// id: i32,
786/// }
787///
788/// // Views also support TABLESPACE:
789/// // #[PostgresView(MATERIALIZED, TABLESPACE = "fast_storage")]
790/// // struct ActiveUsers { id: i32 }
791/// ```
792///
793/// See: <https://www.postgresql.org/docs/current/sql-createtable.html#SQL-CREATETABLE-TABLESPACE>
794pub const TABLESPACE: TableMarker = TableMarker;
795
796//------------------------------------------------------------------------------
797// Column Type Markers
798//------------------------------------------------------------------------------
799
800/// Marker struct for column type attributes.
801#[derive(Debug, Clone, Copy)]
802pub struct TypeMarker;
803
804//--- Character Types ---
805
806/// Specifies a TEXT column type.
807///
808/// TEXT stores variable-length character strings with no length limit.
809///
810/// See: <https://www.postgresql.org/docs/current/datatype-character.html>
811pub const TEXT: TypeMarker = TypeMarker;
812
813/// Specifies a VARCHAR column type.
814///
815/// VARCHAR stores variable-length character strings.
816/// In `PostgreSQL`, VARCHAR without length limit is equivalent to TEXT.
817///
818/// See: <https://www.postgresql.org/docs/current/datatype-character.html>
819pub const VARCHAR: TypeMarker = TypeMarker;
820
821/// Alias for VARCHAR.
822pub const CHARACTER_VARYING: TypeMarker = TypeMarker;
823
824/// Specifies a CHAR column type.
825///
826/// CHAR stores fixed-length character strings.
827///
828/// See: <https://www.postgresql.org/docs/current/datatype-character.html>
829pub const CHAR: TypeMarker = TypeMarker;
830
831/// Alias for CHAR.
832pub const CHARACTER: TypeMarker = TypeMarker;
833
834//--- Integer Types ---
835
836/// Specifies an INTEGER column type (32-bit).
837///
838/// INTEGER (or INT4) stores 32-bit signed integers.
839///
840/// See: <https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-INT>
841pub const INTEGER: TypeMarker = TypeMarker;
842
843/// Alias for INTEGER.
844pub const INT: TypeMarker = TypeMarker;
845
846/// Alias for INTEGER.
847pub const INT4: TypeMarker = TypeMarker;
848
849/// Specifies a BIGINT column type (64-bit).
850///
851/// BIGINT (or INT8) stores 64-bit signed integers.
852///
853/// See: <https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-INT>
854pub const BIGINT: TypeMarker = TypeMarker;
855
856/// Alias for BIGINT.
857pub const INT8: TypeMarker = TypeMarker;
858
859/// Specifies a SMALLINT column type (16-bit).
860///
861/// SMALLINT (or INT2) stores 16-bit signed integers.
862///
863/// See: <https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-INT>
864pub const SMALLINT: TypeMarker = TypeMarker;
865
866/// Alias for SMALLINT.
867pub const INT2: TypeMarker = TypeMarker;
868
869//--- Floating Point Types ---
870
871/// Specifies a REAL column type (32-bit float).
872///
873/// REAL (or FLOAT4) stores 32-bit floating point numbers.
874///
875/// See: <https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-FLOAT>
876pub const REAL: TypeMarker = TypeMarker;
877
878/// Alias for REAL.
879pub const FLOAT4: TypeMarker = TypeMarker;
880
881/// Specifies a DOUBLE PRECISION column type (64-bit float).
882///
883/// DOUBLE PRECISION (or FLOAT8) stores 64-bit floating point numbers.
884///
885/// See: <https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-FLOAT>
886pub const DOUBLE_PRECISION: TypeMarker = TypeMarker;
887
888/// Alias for DOUBLE PRECISION.
889pub const FLOAT8: TypeMarker = TypeMarker;
890
891/// Alias for DOUBLE PRECISION.
892pub const DOUBLE: TypeMarker = TypeMarker;
893
894/// Specifies a NUMERIC column type (arbitrary precision).
895///
896/// NUMERIC stores exact numbers with arbitrary precision.
897///
898/// See: <https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-NUMERIC-DECIMAL>
899pub const NUMERIC: TypeMarker = TypeMarker;
900
901/// Alias for NUMERIC.
902pub const DECIMAL: TypeMarker = TypeMarker;
903
904//--- Boolean Type ---
905
906/// Specifies a BOOLEAN column type.
907///
908/// BOOLEAN stores true/false values.
909///
910/// See: <https://www.postgresql.org/docs/current/datatype-boolean.html>
911pub const BOOLEAN: TypeMarker = TypeMarker;
912
913/// Alias for BOOLEAN.
914pub const BOOL: TypeMarker = TypeMarker;
915
916//--- Binary Type ---
917
918/// Specifies a BYTEA column type (binary data).
919///
920/// BYTEA stores variable-length binary strings.
921///
922/// See: <https://www.postgresql.org/docs/current/datatype-binary.html>
923pub const BYTEA: TypeMarker = TypeMarker;
924
925//--- UUID Type ---
926
927/// Specifies a UUID column type.
928///
929/// UUID stores universally unique identifiers.
930/// Requires the `uuid` feature.
931///
932/// See: <https://www.postgresql.org/docs/current/datatype-uuid.html>
933pub const UUID: TypeMarker = TypeMarker;
934
935//--- Date/Time Types ---
936
937/// Specifies a TIMESTAMP column type (without timezone).
938///
939/// TIMESTAMP stores date and time without timezone.
940///
941/// See: <https://www.postgresql.org/docs/current/datatype-datetime.html>
942pub const TIMESTAMP: TypeMarker = TypeMarker;
943
944/// Alias for TIMESTAMP.
945pub const TIMESTAMP_WITHOUT_TIME_ZONE: TypeMarker = TypeMarker;
946
947/// Specifies a TIMESTAMPTZ column type (with timezone).
948///
949/// TIMESTAMPTZ stores date and time with timezone.
950///
951/// See: <https://www.postgresql.org/docs/current/datatype-datetime.html>
952pub const TIMESTAMPTZ: TypeMarker = TypeMarker;
953
954/// Alias for TIMESTAMPTZ.
955pub const TIMESTAMP_WITH_TIME_ZONE: TypeMarker = TypeMarker;
956
957/// Specifies a DATE column type.
958///
959/// DATE stores calendar dates without time.
960///
961/// See: <https://www.postgresql.org/docs/current/datatype-datetime.html>
962pub const DATE: TypeMarker = TypeMarker;
963
964/// Specifies a TIME column type (without timezone).
965///
966/// TIME stores time of day without date or timezone.
967///
968/// See: <https://www.postgresql.org/docs/current/datatype-datetime.html>
969pub const TIME: TypeMarker = TypeMarker;
970
971/// Alias for TIME.
972pub const TIME_WITHOUT_TIME_ZONE: TypeMarker = TypeMarker;
973
974/// Specifies a TIMETZ column type (with timezone).
975///
976/// TIMETZ stores time of day with timezone.
977///
978/// See: <https://www.postgresql.org/docs/current/datatype-datetime.html>
979pub const TIMETZ: TypeMarker = TypeMarker;
980
981/// Alias for TIMETZ.
982pub const TIME_WITH_TIME_ZONE: TypeMarker = TypeMarker;
983
984/// Specifies an INTERVAL column type.
985///
986/// INTERVAL stores time intervals.
987/// Requires the `chrono` feature.
988///
989/// See: <https://www.postgresql.org/docs/current/datatype-datetime.html>
990pub const INTERVAL: TypeMarker = TypeMarker;
991
992//--- Network Address Types ---
993
994/// Specifies an INET column type.
995///
996/// INET stores IPv4 or IPv6 host addresses.
997/// Requires the `cidr` feature.
998///
999/// See: <https://www.postgresql.org/docs/current/datatype-net-types.html>
1000pub const INET: TypeMarker = TypeMarker;
1001
1002/// Specifies a CIDR column type.
1003///
1004/// CIDR stores IPv4 or IPv6 network addresses.
1005/// Requires the `cidr` feature.
1006///
1007/// See: <https://www.postgresql.org/docs/current/datatype-net-types.html>
1008pub const CIDR: TypeMarker = TypeMarker;
1009
1010/// Specifies a MACADDR column type.
1011///
1012/// MACADDR stores MAC addresses.
1013/// Requires the `cidr` feature.
1014///
1015/// See: <https://www.postgresql.org/docs/current/datatype-net-types.html>
1016pub const MACADDR: TypeMarker = TypeMarker;
1017
1018/// Specifies a MACADDR8 column type.
1019///
1020/// MACADDR8 stores EUI-64 MAC addresses.
1021/// Requires the `cidr` feature.
1022///
1023/// See: <https://www.postgresql.org/docs/current/datatype-net-types.html>
1024pub const MACADDR8: TypeMarker = TypeMarker;
1025
1026//--- Geometric Types ---
1027
1028/// Specifies a POINT column type.
1029///
1030/// POINT stores geometric points.
1031/// Requires the `geo-types` feature.
1032///
1033/// See: <https://www.postgresql.org/docs/current/datatype-geometric.html>
1034pub const POINT: TypeMarker = TypeMarker;
1035
1036/// Specifies a LINE column type.
1037///
1038/// LINE stores infinite geometric lines.
1039/// Requires the `geo-types` feature.
1040///
1041/// See: <https://www.postgresql.org/docs/current/datatype-geometric.html>
1042pub const LINE: TypeMarker = TypeMarker;
1043
1044/// Specifies a LSEG column type.
1045///
1046/// LSEG stores geometric line segments.
1047/// Requires the `geo-types` feature.
1048///
1049/// See: <https://www.postgresql.org/docs/current/datatype-geometric.html>
1050pub const LSEG: TypeMarker = TypeMarker;
1051
1052/// Specifies a BOX column type.
1053///
1054/// BOX stores geometric boxes.
1055/// Requires the `geo-types` feature.
1056///
1057/// See: <https://www.postgresql.org/docs/current/datatype-geometric.html>
1058pub const BOX: TypeMarker = TypeMarker;
1059
1060/// Specifies a PATH column type.
1061///
1062/// PATH stores geometric paths.
1063/// Requires the `geo-types` feature.
1064///
1065/// See: <https://www.postgresql.org/docs/current/datatype-geometric.html>
1066pub const PATH: TypeMarker = TypeMarker;
1067
1068/// Specifies a POLYGON column type.
1069///
1070/// POLYGON stores geometric polygons.
1071/// Requires the `geo-types` feature.
1072///
1073/// See: <https://www.postgresql.org/docs/current/datatype-geometric.html>
1074pub const POLYGON: TypeMarker = TypeMarker;
1075
1076/// Specifies a CIRCLE column type.
1077///
1078/// CIRCLE stores geometric circles.
1079/// Requires the `geo-types` feature.
1080///
1081/// See: <https://www.postgresql.org/docs/current/datatype-geometric.html>
1082pub const CIRCLE: TypeMarker = TypeMarker;
1083
1084//--- Bit String Types ---
1085
1086/// Specifies a BIT column type.
1087///
1088/// BIT stores fixed-length bit strings.
1089/// Requires the `bit-vec` feature.
1090///
1091/// See: <https://www.postgresql.org/docs/current/datatype-bit.html>
1092pub const BIT: TypeMarker = TypeMarker;
1093
1094/// Specifies a VARBIT column type.
1095///
1096/// VARBIT (BIT VARYING) stores variable-length bit strings.
1097/// Requires the `bit-vec` feature.
1098///
1099/// See: <https://www.postgresql.org/docs/current/datatype-bit.html>
1100pub const VARBIT: TypeMarker = TypeMarker;
1101
1102/// Alias for VARBIT.
1103pub const BIT_VARYING: TypeMarker = TypeMarker;