Skip to content

Instantly share code, notes, and snippets.

View fcarrero's full-sized avatar
🏠
Working from home

Franklin Carrero fcarrero

🏠
Working from home
View GitHub Profile
@fcarrero
fcarrero / snowflake-id.sql
Created October 10, 2022 17:16 — forked from beginor/snowflake-id.sql
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;