pub enum DataMigrationSql {
Uniform(String),
PerBackend {
postgres: String,
mysql: String,
sqlite: String,
},
}Expand description
The SQL body of a MigrationAction::DataMigration, either one portable
statement or one statement per backend.
The wire format is untagged, so both shapes are written naturally in a migration file:
{ "type": "data_migration", "sql": "UPDATE product SET price = 0 WHERE price IS NULL" }{
"type": "data_migration",
"sql": {
"postgres": "UPDATE t SET j = jsonb_build_object('ko', c)",
"mysql": "UPDATE t SET j = JSON_OBJECT('ko', c)",
"sqlite": "UPDATE t SET j = json_object('ko', c)"
}
}All three backend keys are required in the per-backend form. A missing key would silently emit nothing for that backend — exactly the class of silent data loss this action exists to prevent.
Variants§
Uniform(String)
One portable statement executed verbatim on every backend.
PerBackend
One statement per backend, for data changes that cannot be expressed portably (JSON constructors, string functions, upsert syntax, …).
Implementations§
Source§impl DataMigrationSql
impl DataMigrationSql
Sourcepub fn statements(&self) -> impl Iterator<Item = &str>
pub fn statements(&self) -> impl Iterator<Item = &str>
Every statement this value can emit, in backend order.
The DDL guard checks all of them: a per-backend form whose sqlite
branch smuggles in a DROP TABLE is just as fatal to baseline replay
as a uniform one.
Trait Implementations§
Source§impl Clone for DataMigrationSql
impl Clone for DataMigrationSql
Source§impl Debug for DataMigrationSql
impl Debug for DataMigrationSql
Source§impl<'de> Deserialize<'de> for DataMigrationSql
impl<'de> Deserialize<'de> for DataMigrationSql
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 DataMigrationSql
Source§impl From<&str> for DataMigrationSql
impl From<&str> for DataMigrationSql
Source§impl From<String> for DataMigrationSql
impl From<String> for DataMigrationSql
Source§impl JsonSchema for DataMigrationSql
impl JsonSchema for DataMigrationSql
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 DataMigrationSql
impl PartialEq for DataMigrationSql
Source§impl Serialize for DataMigrationSql
impl Serialize for DataMigrationSql
impl StructuralPartialEq for DataMigrationSql
Auto Trait Implementations§
impl Freeze for DataMigrationSql
impl RefUnwindSafe for DataMigrationSql
impl Send for DataMigrationSql
impl Sync for DataMigrationSql
impl Unpin for DataMigrationSql
impl UnsafeUnpin for DataMigrationSql
impl UnwindSafe for DataMigrationSql
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