Changelog - 2025-12-31
String ID with Custom Generator
In one line. String IDs are stored in a text column, and you can plug in any ID format (UUID, nanoid, cuid) with a generator function.
What changed
- Text column. String IDs use
textinstead of the PostgreSQLuuidtype. - Custom generator.
generateIdColumnDefsacceptsgeneratorfordataType: 'string'. The default iscrypto.randomUUID(). - Renames.
visibleColumnsis nowvisibleProperties, to matchhiddenProperties. - Principal enricher. The
'uuid'id type is removed; only'number' | 'string'remain.
typescript
import { nanoid } from 'nanoid';
generateIdColumnDefs({
id: {
dataType: 'string',
generator: () => nanoid(),
},
})Who is affected
- Code using
generateIdColumnDefs({ id: { dataType: 'string' } }). It keeps working; only the column type changes fromuuidtotext. - Existing
uuidcolumns. See the database step below. - Code using the old names or the
'uuid'id type. Rename them (below).
Breaking changes
WARNING
Affects code that uses the renamed (internal) members or the removed 'uuid' id type. Most users are not affected.
Before:
typescript
type IdType = 'number' | 'string' | 'uuid';
// _visibleColumns, getVisibleColumns(), visibleColumns getter/setterAfter:
typescript
type IdType = 'number' | 'string';
// _visibleProperties, getVisibleProperties(), visibleProps getter/setterTo move an existing uuid column to text, alter the column type (data is preserved), or keep the uuid type, which still works with the text-based code:
sql
ALTER TABLE "your_table" ALTER COLUMN "id" TYPE TEXT;