UUIDv7 was added to PostgreSQL 18 to support time-based UUIDs, but you don’t have to upgrade to take advantage of them now.

One of the new features released in PostgreSQL 18 is native support for UUIDv7. These UUIDs are time-ordered allowing for the randomness of UUIDs without the fracturing of btree indexes as well as the ability to more accurately sort rows by date using the primary key. While Ruby on Rails supports UUIDs as primary keys, it’s only UUIDv4. That said, you don’t need to upgrade your database or wait for a patch in Rails to take advantage of this new feature today.

To accomplish this, we’ll perform the following steps:

  1. Create a custom database function to generate a UUIDv7 value with the same precision th…

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help