Skip to content

Commit a29e55f

Browse files
committed
Refactor UUID schema
1 parent 68f369b commit a29e55f

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

src/backend/mysql/table.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ impl TableBuilder for MysqlQueryBuilder {
8181
},
8282
ColumnType::Json => "json".into(),
8383
ColumnType::JsonBinary => "json".into(),
84+
ColumnType::Uuid => "binary(16)".into(),
8485
ColumnType::Custom(iden) => iden.to_string(),
85-
ColumnType::Uuid => format!("binary(16)"),
8686
}
8787
)
8888
.unwrap()

src/backend/postgres/table.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ impl TableBuilder for PostgresQueryBuilder {
8181
},
8282
ColumnType::Json => "json".into(),
8383
ColumnType::JsonBinary => "jsonb".into(),
84-
ColumnType::Custom(iden) => iden.to_string(),
8584
ColumnType::Uuid => "uuid".into(),
85+
ColumnType::Custom(iden) => iden.to_string(),
8686
}
8787
)
8888
.unwrap()

src/backend/sqlite/table.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ impl TableBuilder for SqliteQueryBuilder {
101101
},
102102
ColumnType::Json => "text".into(),
103103
ColumnType::JsonBinary => "text".into(),
104-
ColumnType::Custom(iden) => iden.to_string(),
105104
ColumnType::Uuid => "text(36)".into(),
105+
ColumnType::Custom(iden) => iden.to_string(),
106106
}
107107
)
108108
.unwrap()

src/table/column.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ pub enum ColumnType {
3131
Money(Option<(u32, u32)>),
3232
Json,
3333
JsonBinary,
34-
Custom(DynIden),
3534
Uuid,
35+
Custom(DynIden),
3636
}
3737

3838
/// All column specification keywords
@@ -281,21 +281,27 @@ impl ColumnDef {
281281
}
282282

283283
/// Set column type as json.
284-
/// On MySQL, this is equivalent to json_binary. On MariaDB, this is equivalent to text.
285-
/// On PgSQL, this is equivalent to json.
284+
/// On MySQL, this is equivalent to `json_binary`. On MariaDB, this is equivalent to `text`.
285+
/// On PgSQL, this is equivalent to `json`.
286286
pub fn json(mut self) -> Self {
287287
self.types = Some(ColumnType::Json);
288288
self
289289
}
290290

291291
/// Set column type as json binary.
292-
/// On MySQL, this is equivalent to json. On MariaDB, this is equivalent to text.
293-
/// On PgSQL, this is equivalent to jsonb.
292+
/// On MySQL, this is equivalent to `json`. On MariaDB, this is equivalent to `text`.
293+
/// On PgSQL, this is equivalent to `jsonb`.
294294
pub fn json_binary(mut self) -> Self {
295295
self.types = Some(ColumnType::JsonBinary);
296296
self
297297
}
298298

299+
/// Set column type as uuid
300+
pub fn uuid(mut self) -> Self {
301+
self.types = Some(ColumnType::Uuid);
302+
self
303+
}
304+
299305
/// Use a custom type on this column.
300306
pub fn custom<T: 'static>(mut self, n: T) -> Self
301307
where
@@ -322,10 +328,4 @@ impl ColumnDef {
322328
pub fn get_column_spec(&self) -> &Vec<ColumnSpec> {
323329
self.spec.as_ref()
324330
}
325-
326-
/// Set column type as uuid
327-
pub fn uuid(mut self) -> Self {
328-
self.types = Some(ColumnType::Uuid);
329-
self
330-
}
331331
}

0 commit comments

Comments
 (0)