Skip to content

Instantly share code, notes, and snippets.

View peem-strike's full-sized avatar

peem-strike peem-strike

View GitHub Profile
@l1x
l1x / partition.sql
Last active April 23, 2024 11:36
Creating PostgreSQL table partitions automatically based on the date field (type date as well) -- each day is a single partition
CREATE TABLE testing_partition(patent_id BIGINT, date DATE) WITH ( OIDS=FALSE);
CREATE OR REPLACE FUNCTION create_partition_and_insert() RETURNS trigger AS
$BODY$
DECLARE
partition_date TEXT;
partition TEXT;
BEGIN
partition_date := to_char(NEW.date,'YYYY_MM_DD');
partition := TG_TABLE_NAME || '_' || partition_date;
@mislav
mislav / aprompt.png
Last active May 17, 2025 18:20
My zsh prompt. No oh-my-zsh needed
aprompt.png