pub struct MigrationOutcome {
pub from: u32,
pub to: u32,
}Expand description
Bring conn’s database up to SCHEMA_VERSION, or fail explaining why not.
Reading user_version before writing is the whole point. The previous
implementation re-ran every CREATE … IF NOT EXISTS unconditionally and then
stamped the version it had never read, which meant it could not distinguish a
fresh file from a foreign one from a database written by a future build — it
simply asserted the schema it wanted and hoped. IF NOT EXISTS hides exactly
the case that matters: an object that exists with a different definition is
silently kept, so a legacy table would survive with none of its constraints
while the stamp claimed otherwise.
What run did, so a caller can react to the schema having moved.
The one caller that must is Database::open: a SCHEMA_VERSION bump
invalidates every snapshot on disk (D-043), and until Wave 4.4 nothing
noticed — the first reconstruct after an upgrade skipped every snapshot as
incompatible and folded from genesis, correctly and expensively, with the
only trace a warn! per skipped file.
Fields§
§from: u32The version the file carried on the way in.
to: u32SCHEMA_VERSION, always — run either reaches it or fails.
Implementations§
Source§impl MigrationOutcome
impl MigrationOutcome
Sourcepub fn upgraded(&self) -> bool
pub fn upgraded(&self) -> bool
Whether an existing database moved between versions.
A fresh file (from == 0) is deliberately not an upgrade. It has no
snapshots to invalidate, so there is nothing to re-anchor — and treating
it as one made Database::open write a snapshot on every first open,
which broke two contracts the suite already pins: an idle database is
never anchored, and a handle opened with no cadence writes nothing until
close(). Both are worth keeping. open() touching the disk when it was
not asked to is surprising in its own right.
Trait Implementations§
Source§impl Clone for MigrationOutcome
impl Clone for MigrationOutcome
Source§fn clone(&self) -> MigrationOutcome
fn clone(&self) -> MigrationOutcome
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for MigrationOutcome
Source§impl Debug for MigrationOutcome
impl Debug for MigrationOutcome
impl Eq for MigrationOutcome
Source§impl PartialEq for MigrationOutcome
impl PartialEq for MigrationOutcome
impl StructuralPartialEq for MigrationOutcome
Auto Trait Implementations§
impl Freeze for MigrationOutcome
impl RefUnwindSafe for MigrationOutcome
impl Send for MigrationOutcome
impl Sync for MigrationOutcome
impl Unpin for MigrationOutcome
impl UnsafeUnpin for MigrationOutcome
impl UnwindSafe for MigrationOutcome
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request