Skip to content

Commit

Permalink
Add pk_uuid schema helper (#2329)
Browse files Browse the repository at this point in the history
* Add pk_uuid schema helper

* CHANGELOG

---------

Co-authored-by: Billy Chan <ccw.billy.123@gmail.com>
  • Loading branch information
aaroningalls and billy1624 authored Oct 4, 2024
1 parent 8339dbb commit cb5520e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

* [sea-orm-macros] Call `EnumIter::get` using fully qualified syntax https://github.com/SeaQL/sea-orm/pull/2321
* Construct `DatabaseConnection` directly from `sqlx::PgPool`, `sqlx::SqlitePool` and `sqlx::MySqlPool` https://github.com/SeaQL/sea-orm/pull/2348
* [sea-orm-migration] Add `pk_uuid` schema helper https://github.com/SeaQL/sea-orm/pull/2329

### Upgrades

Expand Down
5 changes: 5 additions & 0 deletions sea-orm-migration/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ pub fn pk_auto<T: IntoIden>(name: T) -> ColumnDef {
integer(name).auto_increment().primary_key().take()
}

/// Create a UUID primary key
pub fn pk_uuid<T: IntoIden>(name: T) -> ColumnDef {
uuid(name).primary_key().take()
}

pub fn char_len<T: IntoIden>(col: T, length: u32) -> ColumnDef {
ColumnDef::new(col).char_len(length).not_null().take()
}
Expand Down

0 comments on commit cb5520e

Please sign in to comment.