pub struct Schema {
pub datasource: Option<Datasource>,
pub models: IndexMap<SmolStr, Model>,
pub enums: IndexMap<SmolStr, Enum>,
pub types: IndexMap<SmolStr, CompositeType>,
pub views: IndexMap<SmolStr, View>,
pub server_groups: IndexMap<SmolStr, ServerGroup>,
pub policies: Vec<Policy>,
pub raw_sql: Vec<RawSql>,
pub relations: Vec<Relation>,
}Expand description
A complete Prax schema.
Fields§
§datasource: Option<Datasource>Datasource configuration (database connection and extensions).
models: IndexMap<SmolStr, Model>All models in the schema.
enums: IndexMap<SmolStr, Enum>All enums in the schema.
types: IndexMap<SmolStr, CompositeType>All composite types in the schema.
views: IndexMap<SmolStr, View>All views in the schema.
server_groups: IndexMap<SmolStr, ServerGroup>Server groups for multi-server configurations.
policies: Vec<Policy>PostgreSQL Row-Level Security policies.
raw_sql: Vec<RawSql>Raw SQL definitions.
relations: Vec<Relation>Resolved relations (populated after validation).
Implementations§
Source§impl Schema
impl Schema
Sourcepub fn set_datasource(&mut self, datasource: Datasource)
pub fn set_datasource(&mut self, datasource: Datasource)
Set the datasource configuration.
Sourcepub fn datasource(&self) -> Option<&Datasource>
pub fn datasource(&self) -> Option<&Datasource>
Get the datasource configuration.
Sourcepub fn has_vector_support(&self) -> bool
pub fn has_vector_support(&self) -> bool
Check if the schema has vector extension enabled.
Sourcepub fn required_extensions(&self) -> Vec<&PostgresExtension>
pub fn required_extensions(&self) -> Vec<&PostgresExtension>
Get all required PostgreSQL extensions from the datasource.
Sourcepub fn add_type(&mut self, t: CompositeType)
pub fn add_type(&mut self, t: CompositeType)
Add a composite type to the schema.
Sourcepub fn add_server_group(&mut self, sg: ServerGroup)
pub fn add_server_group(&mut self, sg: ServerGroup)
Add a server group to the schema.
Sourcepub fn add_policy(&mut self, policy: Policy)
pub fn add_policy(&mut self, policy: Policy)
Add a PostgreSQL Row-Level Security policy.
Sourcepub fn add_raw_sql(&mut self, sql: RawSql)
pub fn add_raw_sql(&mut self, sql: RawSql)
Add a raw SQL definition.
Sourcepub fn get_model_mut(&mut self, name: &str) -> Option<&mut Model>
pub fn get_model_mut(&mut self, name: &str) -> Option<&mut Model>
Get a mutable model by name.
Sourcepub fn get_type(&self, name: &str) -> Option<&CompositeType>
pub fn get_type(&self, name: &str) -> Option<&CompositeType>
Get a composite type by name.
Sourcepub fn get_server_group(&self, name: &str) -> Option<&ServerGroup>
pub fn get_server_group(&self, name: &str) -> Option<&ServerGroup>
Get a server group by name.
Sourcepub fn server_group_names(&self) -> impl Iterator<Item = &str>
pub fn server_group_names(&self) -> impl Iterator<Item = &str>
Get all server group names.
Sourcepub fn get_policy(&self, name: &str) -> Option<&Policy>
pub fn get_policy(&self, name: &str) -> Option<&Policy>
Get a policy by name.
Sourcepub fn policies_for(&self, model: &str) -> Vec<&Policy>
pub fn policies_for(&self, model: &str) -> Vec<&Policy>
Get all policies for a specific model/table.
Sourcepub fn has_policies(&self, model: &str) -> bool
pub fn has_policies(&self, model: &str) -> bool
Check if a model has Row-Level Security policies.
Sourcepub fn policy_names(&self) -> impl Iterator<Item = &str>
pub fn policy_names(&self) -> impl Iterator<Item = &str>
Get all policy names.
Sourcepub fn type_exists(&self, name: &str) -> bool
pub fn type_exists(&self, name: &str) -> bool
Check if a type name exists (model, enum, type, or view).
Sourcepub fn model_names(&self) -> impl Iterator<Item = &str>
pub fn model_names(&self) -> impl Iterator<Item = &str>
Get all model names.
Sourcepub fn enum_names(&self) -> impl Iterator<Item = &str>
pub fn enum_names(&self) -> impl Iterator<Item = &str>
Get all enum names.
Sourcepub fn relations_for(&self, model: &str) -> Vec<&Relation>
pub fn relations_for(&self, model: &str) -> Vec<&Relation>
Get relations for a specific model.
Sourcepub fn relations_from(&self, model: &str) -> Vec<&Relation>
pub fn relations_from(&self, model: &str) -> Vec<&Relation>
Get relations originating from a specific model.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Schema
impl<'de> Deserialize<'de> for Schema
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Schema, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Schema, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for Schema
impl Serialize for Schema
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for Schema
Auto Trait Implementations§
impl Freeze for Schema
impl RefUnwindSafe for Schema
impl Send for Schema
impl Sync for Schema
impl Unpin for Schema
impl UnwindSafe for Schema
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more