Feature hasn't been suggested before.
Describe the enhancement you want to request
Since Postgres v18 we can use the
gen_random_uuid -> uuid v4
uuidv4 -> uuid v4
uuidv7 -> uuid v7
https://www.postgresql.org/docs/current/functions-uuid.html
It would be nice to have an optional parameter to defaultRandom function of the UUID column builder to easily choose between v4 and v7 (and keep a default to v4 for backward compatibility).
|
/** |
|
* Adds `default gen_random_uuid()` to the column definition. |
|
*/ |
|
defaultRandom(): ReturnType<this['default']> { |
|
return this.default(sql`gen_random_uuid()`) as ReturnType<this['default']>; |
|
} |
Alternative
We can do the following
uuid('id').primaryKey().default(sql`uuidv7()`),
Feature hasn't been suggested before.
Describe the enhancement you want to request
Since Postgres v18 we can use the
gen_random_uuid-> uuid v4uuidv4-> uuid v4uuidv7-> uuid v7https://www.postgresql.org/docs/current/functions-uuid.html
It would be nice to have an optional parameter to
defaultRandomfunction of the UUID column builder to easily choose betweenv4andv7(and keep a default to v4 for backward compatibility).drizzle-orm/drizzle-orm/src/pg-core/columns/uuid.ts
Lines 24 to 29 in 48e5406
Alternative
We can do the following