wiki.hjertnes.website

Postgres and UUID

If you want to use UUID with postgres. This works with the current version of Postgres as of early 2021; not sure how long back it works CREATE EXTENSION pgcrypto; You need to run this on all databases that use this. It enables functions that let you generate UUID's inside queryies without manually doing it outside SQL. create table folders(id uuid primary key not null default gen_random_uuid() unique, title text) This creates a table with a primary key that is a UUID and it uses functions from pgcrypto to automatically set it to the ID when you create new rows.