Skip to main content

Generator

Struct Generator 

Source
pub struct Generator {
    pub breakpoints: bool,
}
Available on crate feature std only.

Fields§

§breakpoints: bool

Implementations§

Source§

impl Generator

Source

pub const fn new() -> Generator

Source

pub const fn with_breakpoints(self, breakpoints: bool) -> Generator

Source

pub fn generate(&self, diff: &[EntityDiff]) -> Vec<String>

Generate SQL statements from a set of entity diffs.

§Panics

Panics if a table listed in created_tables is not found in diff — this cannot happen in practice because created_tables is built from diff itself.

Source

pub fn generate_with_ddl( &self, diff: &[EntityDiff], cur_ddl: Option<&PostgresDDL>, ) -> Vec<String>

Generate SQL statements from a set of entity diffs, with access to the full current DDL for cross-entity lookups (e.g. finding the columns that depend on an enum being recreated).

Statement ordering is dependency-phased:

  1. creates of schemas → enums → sequences → roles,
  2. drops of views,
  3. drops of table sub-entities on surviving tables (FKs/indexes/constraints/policies before columns),
  4. table drops in reverse dependency order,
  5. table creates in dependency order (with inlined sub-entities),
  6. sub-entity creates on pre-existing tables (columns first),
  7. alters (including ALTER COLUMN ... USING enum conversions),
  8. enum and sequence drops (after alters so USING casts run before DROP TYPE),
  9. view creates,
  10. role and schema drops.
§Panics

Panics if a table listed in created_tables is not found in diff — this cannot happen in practice because created_tables is built from diff itself.

Trait Implementations§

Source§

impl Default for Generator

Source§

fn default() -> Generator

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

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> AliasExt for T

Source§

fn alias(self, name: &'static str) -> AliasedExpr<Self>

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> 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<Mk> MarkerAggValidFor<()> for Mk

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<Scope> ScopeSatisfies<Nil, ()> for Scope

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, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> TypeEq<T> for T