gize_db/lib.rs
1//! Data-layer conventions for Gize (ADR-003, ADR-011).
2//!
3//! MVP scope is intentionally thin: it centralises the mapping between Gize field types
4//! and Postgres column types so generators and (future) migration diffing agree. The
5//! SQLx pool wiring lives in generated app code, not here.
6
7use gize_core::FieldType;
8
9pub mod admin;
10pub mod migrate;
11
12/// The Postgres column type for a Gize field type. Single source of truth reused by the
13/// migration templates.
14pub fn pg_column_type(ty: FieldType) -> &'static str {
15 ty.sql_type()
16}
17
18#[cfg(test)]
19mod tests {
20 use super::*;
21
22 #[test]
23 fn maps_known_types() {
24 assert_eq!(pg_column_type(FieldType::String), "TEXT");
25 assert_eq!(pg_column_type(FieldType::Uuid), "UUID");
26 assert_eq!(pg_column_type(FieldType::DateTime), "TIMESTAMPTZ");
27 }
28}