Skip to content

use Postgres built-in uuid 4 function#1323

Merged
sinisaos merged 1 commit intopiccolo-orm:masterfrom
sinisaos:built_in_uuid_4
Jan 11, 2026
Merged

use Postgres built-in uuid 4 function#1323
sinisaos merged 1 commit intopiccolo-orm:masterfrom
sinisaos:built_in_uuid_4

Conversation

@sinisaos
Copy link
Member

Related to #1309

@sinisaos sinisaos merged commit 1945476 into piccolo-orm:master Jan 11, 2026
46 checks passed
@sinisaos sinisaos deleted the built_in_uuid_4 branch January 11, 2026 10:26
@dantownsend
Copy link
Member

I think this is good, thanks.

My only concern is with existing users. Their existing UUID columns will still use the uuid extension. I think our options are:

  1. Leave extensions = ("uuid-ossp",), for now
  2. Write something in the docs about it - so users can manually set the extensions value, or we could provide some kind of migration script for converting existing columns
  3. Make Piccolo auto migrations understand this change, but this might be tricky

It can be done in a separate issue.

@sinisaos
Copy link
Member Author

I think we can safely make this transition because the generated UUID is identical from both functions. I think we are also safe with older migrations because we don't use hard-coded values ​​(e.g in the migration we use the UUID4 class, not gen_random_uuid() or uuid_generate_v4()). If we used these hard-coded values, the user would have to change them in every older migration, which is not the case. I tried generating the UUID PK using the extension and then I change to gen_random_uuid() and was able to use the existing records with the extension generated UUID and everything was fine. I'm sorry if I'm wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants