From 9b52865d8ee09c6aeeaaba293b324fb9d75b34eb Mon Sep 17 00:00:00 2001 From: Hampton Lintorn-Catlin Date: Tue, 24 Feb 2026 14:32:50 -0600 Subject: [PATCH] Switch UUID generation from v4 to v7 Use SecureRandom.uuid_v7 (Ruby 3.4+) instead of SecureRandom.uuid (v4). UUIDv7 (RFC 9562) embeds a 48-bit unix timestamp, so primary keys naturally sort chronologically. This fixes comment reply ordering and improves B-tree index locality. Amp-Thread-ID: https://ampcode.com/threads/T-019c9157-b075-7443-9d10-f4aa772fec8f Co-authored-by: Amp --- app/models/application_record.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 828ef2d8..37ddd999 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -6,6 +6,6 @@ class ApplicationRecord < ActiveRecord::Base private def assign_uuid - self.id = SecureRandom.uuid + self.id = SecureRandom.uuid_v7 end end