#[non_exhaustive]pub enum UniqueConstraintStrategy {
DeleteDuplicates {
keep: KeepPolicy,
},
}Expand description
How AddConstraint(Unique) should handle pre-existing duplicate rows.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
DeleteDuplicates
Emit a DELETE statement just before the ADD CONSTRAINT so only
one row per group of duplicates survives. keep picks which one.
This is the only strategy in v0.2 — see module docs.
Fields
keep: KeepPolicyWhich row of each duplicate group is preserved. See
KeepPolicy.
Trait Implementations§
Source§impl Clone for UniqueConstraintStrategy
impl Clone for UniqueConstraintStrategy
Source§fn clone(&self) -> UniqueConstraintStrategy
fn clone(&self) -> UniqueConstraintStrategy
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 UniqueConstraintStrategy
impl Debug for UniqueConstraintStrategy
Source§impl Default for UniqueConstraintStrategy
impl Default for UniqueConstraintStrategy
Source§fn default() -> Self
fn default() -> Self
Default strategy is DeleteDuplicates { keep: First }: keep the
row with the smallest primary-key value of each duplicate group.
This is what wire-format-omitted strategy (v0.1.x migrations or
any JSON without the field) deserializes to.
Wire-format breaking change vs v0.1.x. v0.1.x emitted no
pre-cleanup and let the database reject the migration. v0.2 emits
a DELETE automatically. Existing migrations that already
applied under v0.1.x are unaffected (apply happens once); v0.1.x
migrations re-run against a fresh DB will now drop duplicate
rows instead of failing.
Source§impl<'de> Deserialize<'de> for UniqueConstraintStrategy
impl<'de> Deserialize<'de> for UniqueConstraintStrategy
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 UniqueConstraintStrategy
Source§impl Hash for UniqueConstraintStrategy
impl Hash for UniqueConstraintStrategy
Source§impl JsonSchema for UniqueConstraintStrategy
impl JsonSchema for UniqueConstraintStrategy
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 Ord for UniqueConstraintStrategy
impl Ord for UniqueConstraintStrategy
Source§fn cmp(&self, other: &UniqueConstraintStrategy) -> Ordering
fn cmp(&self, other: &UniqueConstraintStrategy) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for UniqueConstraintStrategy
impl PartialEq for UniqueConstraintStrategy
Source§fn eq(&self, other: &UniqueConstraintStrategy) -> bool
fn eq(&self, other: &UniqueConstraintStrategy) -> bool
self and other values to be equal, and is used by ==.Source§impl PartialOrd for UniqueConstraintStrategy
impl PartialOrd for UniqueConstraintStrategy
Source§impl Serialize for UniqueConstraintStrategy
impl Serialize for UniqueConstraintStrategy
impl StructuralPartialEq for UniqueConstraintStrategy
Auto Trait Implementations§
impl Freeze for UniqueConstraintStrategy
impl RefUnwindSafe for UniqueConstraintStrategy
impl Send for UniqueConstraintStrategy
impl Sync for UniqueConstraintStrategy
impl Unpin for UniqueConstraintStrategy
impl UnsafeUnpin for UniqueConstraintStrategy
impl UnwindSafe for UniqueConstraintStrategy
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