pub enum Operation {
CreateModel {
name: String,
fields: Vec<Field>,
},
RenameModel {
old: String,
new: String,
},
DeleteModel {
name: String,
},
CreateField {
model: String,
field: Field,
},
RenameField {
table_name: String,
old: String,
new: String,
},
SetFieldType {
model: String,
name: String,
db_type: DbType,
},
SetFieldMaxLength {
model: String,
name: String,
max_length: i32,
},
DropFieldMaxLength {
model: String,
name: String,
},
DeleteField {
model: String,
name: String,
},
CreateIndex {
model: String,
index: Index,
},
DeleteIndex {
model: String,
index: Index,
},
RawSQL {
structure_safe: bool,
sqlite: String,
postgres: String,
mysql: String,
},
}Expand description
The representation for all possible database operations
Variants§
CreateModel
Representation of a CreateModel operation
RenameModel
Representation of a RenameModel operation
DeleteModel
Representation of a DeleteModel operation
CreateField
Representation of a CreateField operation
RenameField
Representation of a RenameField operation
Fields
SetFieldType
Representation of a SetFieldType operation
It changes an existing column’s type in place, preserving its data.
The type has to be one which is fully described by itself. A
DbType::VarChar carries its maximum length and a DbType::Choices
its enum, so neither can be set through this operation.
Fields
SetFieldMaxLength
Representation of a SetFieldMaxLength operation
It constrains a DbType::Text column to a maximum length. Postgres
enforces it with a check constraint; sqlite has no varchar and never
checks a string’s length, so there it does nothing.
A column which already has a maximum length has to drop it first: a constraint can’t be redefined, only replaced.
Fields
DropFieldMaxLength
Representation of a DropFieldMaxLength operation
It removes the constraint Operation::SetFieldMaxLength created.
DeleteField
Representation of a DeleteField operation
CreateIndex
Representation of a CreateIndex operation
Fields
DeleteIndex
Representation of a DeleteIndex operation
Fields
RawSQL
Representation of a RawSQL operation