Skip to content

Commit d6f7bcf

Browse files
committed
ver bump with migration
1 parent 21ba825 commit d6f7bcf

3 files changed

Lines changed: 44 additions & 42 deletions

File tree

apps/api/migrations/2026-03-01-uuidv7.sql

Lines changed: 0 additions & 39 deletions
This file was deleted.

apps/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kaja/cli",
3-
"version": "0.0.27",
3+
"version": "0.0.28",
44
"type": "module",
55
"private": true,
66
"scripts": {

docs/deployment.md

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,49 @@ Notes.
1616
1717
Attaching PostgreSQL instance to the API project in Disco automatically creates the `DATABASE_URL` env var.
1818

19-
On the server, first run `2026-03-01-uuidv7.sql` manually.
20-
19+
If `uuidv7()` missing from the server, create it manually:
20+
21+
```sql
22+
CREATE EXTENSION IF NOT EXISTS pgcrypto;
23+
24+
DO $$
25+
BEGIN
26+
IF NOT EXISTS (
27+
SELECT 1
28+
FROM pg_proc
29+
WHERE proname = 'uuidv7'
30+
AND pronargs = 0
31+
AND pg_function_is_visible(oid)
32+
) THEN
33+
CREATE FUNCTION uuidv7()
34+
RETURNS uuid
35+
LANGUAGE plpgsql
36+
VOLATILE
37+
AS $fn$
38+
DECLARE
39+
ts bytea;
40+
rnd bytea;
41+
BEGIN
42+
ts := substring(
43+
int8send(floor(extract(epoch FROM clock_timestamp()) * 1000)::bigint)
44+
FROM 3
45+
);
46+
47+
rnd := gen_random_bytes(10);
48+
49+
-- UUIDv7 version bits
50+
rnd := set_byte(rnd, 0, (get_byte(rnd, 0) & 15) | 112);
51+
52+
-- UUID variant bits
53+
rnd := set_byte(rnd, 2, (get_byte(rnd, 2) & 63) | 128);
54+
55+
RETURN encode(ts || rnd, 'hex')::uuid;
56+
END;
57+
$fn$;
58+
END IF;
59+
END
60+
$$;
61+
```
2162

2263
<!-- # Configuration
2364

0 commit comments

Comments
 (0)