From cb5520eb670d63ee6ee516a7707299e02adba56b Mon Sep 17 00:00:00 2001
From: Aaron Ingalls <aaroningalls@hotmail.com>
Date: Fri, 4 Oct 2024 04:40:08 -0500
Subject: [PATCH] Add pk_uuid schema helper (#2329)

* Add pk_uuid schema helper

* CHANGELOG

---------

Co-authored-by: Billy Chan <ccw.billy.123@gmail.com>
---
 CHANGELOG.md                    | 1 +
 sea-orm-migration/src/schema.rs | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 567c2d9d4..30e3226e8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
 
diff --git a/sea-orm-migration/src/schema.rs b/sea-orm-migration/src/schema.rs
index 47ecd05d6..dda97bcf4 100644
--- a/sea-orm-migration/src/schema.rs
+++ b/sea-orm-migration/src/schema.rs
@@ -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()
 }