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 migrate;
10
11/// The Postgres column type for a Gize field type. Single source of truth reused by the
12/// migration templates.
13pub fn pg_column_type(ty: FieldType) -> &'static str {
14 ty.sql_type()
15}
16
17#[cfg(test)]
18mod tests {
19 use super::*;
20
21 #[test]
22 fn maps_known_types() {
23 assert_eq!(pg_column_type(FieldType::String), "TEXT");
24 assert_eq!(pg_column_type(FieldType::Uuid), "UUID");
25 assert_eq!(pg_column_type(FieldType::DateTime), "TIMESTAMPTZ");
26 }
27}