Skip to main content

SchemaModel

Struct SchemaModel 

Source
pub struct SchemaModel {
    pub manage_comments: bool,
    pub manage_functions: bool,
    pub schemas: Vec<String>,
    pub tables: Vec<TableModel>,
    pub functions: Vec<FunctionModel>,
}
Expand description

数据库整体结构:schema 列表 + 表列表。

三种来源都会归一化到该模型:

  1. Rust struct(期望结构,由 #[derive(DbSchema)] 生成)
  2. PostgreSQL 元数据(实际结构,由 introspection 读取)

Fields§

§manage_comments: bool

是否把表/字段注释纳入差异管理。默认 false,兼容旧 JSON。

§manage_functions: bool

是否把数据库函数纳入差异管理。默认 false,兼容旧 JSON。

§schemas: Vec<String>

需要确保存在的 schema 名称(public 由 PostgreSQL 自带,无需列出)

§tables: Vec<TableModel>

全部业务表(期望结构或实际结构)

§functions: Vec<FunctionModel>

数据库函数。函数以 schema + 名称 + identity arguments 唯一标识。

Implementations§

Source§

impl SchemaModel

Source

pub fn new(schemas: Vec<String>, tables: Vec<TableModel>) -> SchemaModel

构造一个完整的结构模型

Source

pub fn with_functions( schemas: Vec<String>, tables: Vec<TableModel>, functions: Vec<FunctionModel>, ) -> SchemaModel

构造包含数据库函数的完整模型。

Source

pub fn from_tables(tables: Vec<TableModel>) -> SchemaModel

由一组表构造模型,并自动收集它们所属的 schema(跳过 public)

Source

pub fn is_empty(&self) -> bool

是否没有任何受管理对象

Trait Implementations§

Source§

impl Clone for SchemaModel

Source§

fn clone(&self) -> SchemaModel

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SchemaModel

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for SchemaModel

Source§

fn default() -> SchemaModel

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for SchemaModel

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<SchemaModel, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for SchemaModel

Source§

impl PartialEq for SchemaModel

Source§

fn eq(&self, other: &SchemaModel) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for SchemaModel

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for SchemaModel

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.