[ Updating Audits ] - Auditing UUIDs? #325
KofTwentyTwo
announced in
Daily Build Log
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Auditing UUIDs? Yes, Now You Can.
The QQQ audit system now supports tables with any primary key type - not just integers.
This landed in [issue #322].
Why This Matters
Not every table uses integer primary keys. UUIDs are common in distributed systems. External integrations hand you string IDs. Some domains have natural keys that aren't numbers.
UUIDs are also a common requirement for compliance frameworks like HIPAA and SOC2, where predictable sequential IDs can leak information about record counts or creation timing. If your security team mandates UUIDs, your audit system needs to keep up.
The audit system was built for integer PKs. Now it handles whatever you throw at it.
How It Works
AuditsMetaDataProvideraccepts a newrecordIdTypeconfiguration:In STRING mode, the audit table's
recordIdcolumn stores text values. Integer PKs convert automatically, so you can mix integer and string-keyed tables in the same application. The system handles the type conversion transparently.Example: Document Management
Say you're building a document management system where documents have UUID identifiers:
With STRING mode enabled, every insert, update, and delete on this table gets a complete audit trail - who changed what, when, and what the values were before and after.
What Changed Under the Hood
withRecordIdType()fluent configurationrecordIdfield now acceptsSerializable(Integer, String, UUID)DDL Examples
INTEGER Mode (Default)
STRING Mode
The
VARCHAR(36)accommodates standard UUID format (32 hex chars + 4 hyphens). Adjust the length if your string keys are longer.Migrating an Existing Deployment
If you're switching from INTEGER to STRING mode on an existing system:
Existing integer values in the
record_idcolumn will be preserved and work correctly - the database handles the implicit conversion when reading.Suggested Indexes
Audit tables grow fast. Without indexes, queries slow to a crawl. Here's what we recommend:
The composite index on
(audit_table_id, record_id, timestamp)covers the most common access pattern: fetching the audit trail for a single record, sorted by time. If you only add one index, make it that one.Backwards Compatibility
This is a pure addition. The default remains INTEGER. Existing deployments continue working without any changes. No migrations required unless you want STRING mode.
Which Mode Should You Use?
Stick with INTEGER (default) if:
Switch to STRING if:
The storage difference is minimal. A few extra bytes per audit record won't matter for most applications. Choose based on your data model, not premature optimization.
All reactions