Skip to content

Instantly share code, notes, and snippets.

@s7anley
s7anley / update
Last active August 29, 2015 13:56
Update Enum Type Item (Label) in PostgreSQL
-- Update one label in custom enum type
UPDATE pg_enum SET enumlabel = 'new_value'
WHERE enumlabel = 'old_value' AND enumtypid = (
SELECT oid FROM pg_type WHERE typname = 'enum_type'
);
-- Add new label in custom type avaliable since PostgreSQL 9.1
ALTER TYPE enum_type ADD VALUE 'new_value' BEFORE 'old_value';
ALTER TYPE enum_type ADD VALUE 'new_value' AFTER 'old_value';
@s7anley
s7anley / delete_local_branches
Last active December 20, 2015 02:59
Delete local already merged branches and update the local database of remote branches.
# Delete all branches already merged to current branch
git checkout master; git branch --merged | grep -v "\*" | xargs -n 1 git branch -d
# Sync local database of remote branchces
git fetch -p