Skip to main content

schema_reverse_engineer/
info.rs

1//! Dialect-neutral rows produced by the database readers and consumed by `reader.rs`.
2
3use schema_model::model::column_type::ColumnType;
4
5#[derive(Debug, Clone)]
6pub struct ColumnInfo {
7    pub table_name: String,
8    pub column_name: String,
9    pub column_type: ColumnType,
10    pub length: i32,
11    pub scale: i32,
12    pub required: bool,
13    pub default_constraint: Option<String>,
14    pub generated: Option<String>,
15    pub enum_type: Option<String>,
16    pub element_type: Option<String>,
17}
18
19#[derive(Debug, Clone, Default)]
20pub struct KeyInfo {
21    pub columns: Vec<String>,
22    /// Non-key `INCLUDE` columns (covering index).
23    pub include: Vec<String>,
24    /// Bare predicate of a partial index (`WHERE ...`).
25    pub filter: Option<String>,
26    pub unique: bool,
27}
28
29#[derive(Debug, Clone, Default)]
30pub struct TableKeys {
31    pub primary: Option<KeyInfo>,
32    pub unique: Vec<KeyInfo>,
33    pub index: Vec<KeyInfo>,
34}