Skip to content

Instantly share code, notes, and snippets.

@marcocarvalho
Last active April 20, 2020 14:29
Show Gist options
  • Save marcocarvalho/ee7fcf288d0c51639bcd5f625c340057 to your computer and use it in GitHub Desktop.
Save marcocarvalho/ee7fcf288d0c51639bcd5f625c340057 to your computer and use it in GitHub Desktop.
Remove branches from CM
# select concat('drop database if exists ', datname, ';') from pg_database where left(datname, 11) = 'caremessage' and datname not like '%master%' and datname not like '%staging%'
ignores=(\* master staging)
for branch in $(git branch)
do
if [[ " ${ignores[@]} " =~ " ${branch} " || "$CURRENT_WORK" = "$branch" ]]; then continue; fi
git checkout $branch
if [[ "$?" != "0" ]]; then continue; fi
echo "drop database if exists caremessage_dev_$branch;" >> drop_databases.sql
echo "drop database if exists caremessage_test_$branch;" >> drop_databases.sql
git checkout master
git branch -D $branch
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment