Commit ac01e82
feat(drizzle): add uuidv7 support (#16113)
## Goal
Let projects use **UUID v7** (time-ordered UUIDs) for collection IDs via
`idType: 'uuidv7'` on Postgres-related adapters (and SQLite wiring),
while keeping the same storage shape as v4 UUIDs (native `uuid` on
Postgres, text on SQLite).
### What?
- Adds a new adapter option `idType: 'uuidv7'` alongside existing
`'serial' | 'uuid'` (Postgres) and `'number' | 'uuid'` (SQLite).
- Generates IDs in application code with `uuid` package `v7()` (not
database-native), so older Postgres versions are still supported.
- Reuses the same Drizzle column modeling as UUID v4 where appropriate
(`defaultV7` on the raw column, `$defaultFn` / generated schema code).
- Adds integration tests behind `PAYLOAD_DATABASE=postgres-uuidv7` and a
test adapter preset `postgres-uuidv7`.
### Why?
UUID v7 is sortable by creation time and tends to be friendlier for
B-tree indexes than random UUID v4, without changing the wire format or
Postgres column type.
### How?
- Bump `uuid` in `@payloadcms/drizzle` to a version that exports `v7`.
- Extend TypeScript `idType` unions and `UUIDRawColumn` with
`defaultV7`.
- In schema builders (`setColumnID`, `buildDrizzleTable`,
`columnToCodeConverter`), set app-side defaults for v7; treat `uuidv7`
like `uuid` for relationships and query sanitization via a small
`isUUIDType` helper and `getCollectionIdType` mapping to `'text'`.
Fixes #11449
---
- To see the specific tasks where the Asana app for GitHub is being
used, see below:
- https://app.asana.com/0/0/1213991890379567
---------
Co-authored-by: Sasha Rakhmatulin <sasha@ritsuko.dev>1 parent 79f4cc7 commit ac01e82
File tree
44 files changed
+652
-461
lines changed- .github
- actions/start-database
- workflows
- packages
- db-d1-sqlite
- src
- db-mongodb
- db-postgres
- src
- db-sqlite
- src
- db-vercel-postgres
- src
- drizzle
- src
- postgres
- schema
- queries
- schema
- sqlite
- schema
- utilities
- next
- payload
- plugin-stripe
- richtext-lexical
- ui
- test
- _community
- custom-graphql
- database
- relationships
- uuid-v7
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
44 files changed
+652
-461
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| 18 | + | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
| 137 | + | |
137 | 138 | | |
138 | 139 | | |
139 | 140 | | |
| 141 | + | |
140 | 142 | | |
141 | 143 | | |
142 | 144 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
87 | 86 | | |
88 | 87 | | |
89 | 88 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
65 | 64 | | |
66 | 65 | | |
67 | 66 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
89 | 88 | | |
90 | 89 | | |
91 | 90 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| |||
0 commit comments