Skip to content

Instantly share code, notes, and snippets.

@evolkmann
evolkmann / postgres_serial_to_uuid.sql
Created October 25, 2021 21:01
Change a serial ID column to a UUID column with predictable values
alter table example_table
alter column id drop default,
alter column id set data type uuid using uuid_generate_v5(uuid_ns_url(), id::text),
alter column id set default gen_random_uuid();