#[non_exhaustive]pub enum NarrowingStrategy {
Truncate,
Delete,
SetToValue {
value: String,
},
}Expand description
How an existing row that violates the new (narrowed) column type should
be transformed before the ALTER COLUMN TYPE statement runs.
The wire format uses an internally tagged JSON representation
({"kind": "..."}) so future variants stay backwards compatible. The
enum is #[non_exhaustive] — downstream match expressions must
include a wildcard arm.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Truncate
Trim the violating value to fit the new type. The row is preserved; only the column value loses its overflowing tail.
Applicable to string-like narrowings (varchar(N), char(N),
text -> varchar(N)) via LEFT(col, N) / substr(col, 1, N), and
to NUMERIC scale narrowing via ROUND(col, new_scale).
Not applicable to integer / float / timezone narrowings — truncation has no natural definition there. The CLI revision UI hides this option for those cases.
Delete
Delete the entire row containing a violating value. Other columns of that row are lost along with it.
Universally applicable across every narrowing kind. Watch for FK
cascade behaviour — deleting a parent row with ON DELETE CASCADE
can propagate into child tables.
SetToValue
Replace the violating value with a fixed sentinel that fits the new type. The row is preserved; only the violating column is rewritten.
The value field is emitted verbatim into the generated SQL
(UPDATE ... SET col = <value>), so callers must quote string
literals themselves (e.g. "'TRUNCATED'", not "TRUNCATED") and
must ensure the value itself fits the new type — otherwise the
migration will fail in a different way.
Universally applicable across every narrowing kind, including
integer overflow (e.g. value: "0") and timezone loss
(e.g. value: "(now() AT TIME ZONE 'UTC')").
Implementations§
Source§impl NarrowingStrategy
impl NarrowingStrategy
Sourcepub fn kind_label(&self) -> &'static str
pub fn kind_label(&self) -> &'static str
Tag name used in JSON wire format and CLI output (truncate,
delete, set_to_value). #[non_exhaustive] is enforced at
downstream-crate boundaries; this in-crate match is exhaustive.
Trait Implementations§
Source§impl Clone for NarrowingStrategy
impl Clone for NarrowingStrategy
Source§fn clone(&self) -> NarrowingStrategy
fn clone(&self) -> NarrowingStrategy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for NarrowingStrategy
impl Debug for NarrowingStrategy
Source§impl<'de> Deserialize<'de> for NarrowingStrategy
impl<'de> Deserialize<'de> for NarrowingStrategy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for NarrowingStrategy
Source§impl JsonSchema for NarrowingStrategy
impl JsonSchema for NarrowingStrategy
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for NarrowingStrategy
impl PartialEq for NarrowingStrategy
Source§fn eq(&self, other: &NarrowingStrategy) -> bool
fn eq(&self, other: &NarrowingStrategy) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for NarrowingStrategy
impl Serialize for NarrowingStrategy
impl StructuralPartialEq for NarrowingStrategy
Auto Trait Implementations§
impl Freeze for NarrowingStrategy
impl RefUnwindSafe for NarrowingStrategy
impl Send for NarrowingStrategy
impl Sync for NarrowingStrategy
impl Unpin for NarrowingStrategy
impl UnsafeUnpin for NarrowingStrategy
impl UnwindSafe for NarrowingStrategy
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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