90353d8161
Doc Clean Structure * outline * isdocclean * placeholder for clean log * versionplustesting * versionplustesting * testspassed
20 lines
434 B
PL/PgSQL
20 lines
434 B
PL/PgSQL
CREATE EXTENSION IF NOT EXISTS "pgcrypto";
|
|
|
|
create or replace function uuid_generate_v7()
|
|
returns uuid
|
|
as $$
|
|
select encode(
|
|
set_bit(
|
|
set_bit(
|
|
overlay(uuid_send(gen_random_uuid())
|
|
placing substring(int8send(floor(extract(epoch from clock_timestamp()) * 1000)::bigint) from 3)
|
|
from 1 for 6
|
|
),
|
|
52, 1
|
|
),
|
|
53, 1
|
|
),
|
|
'hex')::uuid;
|
|
$$
|
|
language SQL
|
|
volatile; |