pub struct RiskEngine {
pub row_counts: HashMap<String, u64>,
pub live_schema: Option<LiveSchema>,
pub pg_version: u32,
}Fields§
§row_counts: HashMap<String, u64>Estimated rows per table – supplied by the user via –table-rows flag OR imported from the live database via –db-url.
live_schema: Option<LiveSchema>Optional live schema snapshot fetched via –db-url.
pg_version: u32Target PostgreSQL major version (e.g. 14 for PG14). Rules adapt their scoring based on this value — e.g. ADD COLUMN with a DEFAULT is metadata-only on PG11+ but triggers a full table rewrite on PG10 and below. Defaults to 14 (current PostgreSQL LTS).
Implementations§
Source§impl RiskEngine
impl RiskEngine
pub fn new(row_counts: HashMap<String, u64>) -> Self
Sourcepub fn with_pg_version(self, version: u32) -> Self
pub fn with_pg_version(self, version: u32) -> Self
Set the target PostgreSQL major version for version-aware scoring.
Example: .with_pg_version(11) activates PG11+ metadata-only rules.
Sourcepub fn with_live_schema(
row_counts: HashMap<String, u64>,
live: LiveSchema,
) -> Self
pub fn with_live_schema( row_counts: HashMap<String, u64>, live: LiveSchema, ) -> Self
Create an engine seeded from a live database snapshot.
Row counts from live override any manually provided row_counts.
Sourcepub fn analyze(
&self,
file: &str,
statements: &[ParsedStatement],
) -> MigrationReport
pub fn analyze( &self, file: &str, statements: &[ParsedStatement], ) -> MigrationReport
Run every rule against the parsed statements and build a graph, then return the final report for the file.
Auto Trait Implementations§
impl Freeze for RiskEngine
impl RefUnwindSafe for RiskEngine
impl Send for RiskEngine
impl Sync for RiskEngine
impl Unpin for RiskEngine
impl UnsafeUnpin for RiskEngine
impl UnwindSafe for RiskEngine
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> 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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more