Skip to content

Instantly share code, notes, and snippets.

View occluder's full-sized avatar
🍯
There is no honey

Elias A. occluder

🍯
There is no honey
View GitHub Profile
@beginor
beginor / snowflake-id.sql
Last active November 14, 2024 07:54
Twitter Snowflake ID for PostgreSQL
CREATE SEQUENCE public.global_id_seq;
ALTER SEQUENCE public.global_id_seq OWNER TO postgres;
CREATE OR REPLACE FUNCTION public.id_generator()
RETURNS bigint
LANGUAGE 'plpgsql'
AS $BODY$
DECLARE
our_epoch bigint := 1314220021721;
seq_id bigint;