Skip to main content

sqlx_gen/introspect/
mod.rs

1pub mod mysql;
2pub mod postgres;
3pub mod sqlite;
4
5#[derive(Debug, Clone)]
6#[allow(unused)]
7pub struct ColumnInfo {
8    pub name: String,
9    /// High-level data type (e.g. "integer", "character varying")
10    pub data_type: String,
11    /// Underlying type name: udt_name (PG), column_type (MySQL), declared type (SQLite)
12    pub udt_name: String,
13    pub is_nullable: bool,
14    pub is_primary_key: bool,
15    pub ordinal_position: i32,
16    pub schema_name: String,
17    /// Raw column default expression (e.g. `'idle'::task_status`)
18    pub column_default: Option<String>,
19}
20
21#[derive(Debug, Clone)]
22pub struct TableInfo {
23    pub schema_name: String,
24    pub name: String,
25    pub columns: Vec<ColumnInfo>,
26}
27
28#[derive(Debug, Clone)]
29pub struct EnumInfo {
30    pub schema_name: String,
31    pub name: String,
32    pub variants: Vec<String>,
33    /// Default variant name (raw SQL value, e.g. "idle"), if any column uses this enum with a DEFAULT.
34    pub default_variant: Option<String>,
35}
36
37#[derive(Debug, Clone)]
38pub struct CompositeTypeInfo {
39    pub schema_name: String,
40    pub name: String,
41    pub fields: Vec<ColumnInfo>,
42}
43
44#[derive(Debug, Clone)]
45pub struct DomainInfo {
46    pub schema_name: String,
47    pub name: String,
48    /// The underlying SQL type
49    pub base_type: String,
50}
51
52#[derive(Debug, Clone, Default)]
53pub struct SchemaInfo {
54    pub tables: Vec<TableInfo>,
55    pub views: Vec<TableInfo>,
56    pub enums: Vec<EnumInfo>,
57    pub composite_types: Vec<CompositeTypeInfo>,
58    pub domains: Vec<DomainInfo>,
59}