Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Downgrade PostgreSQL on Semaphore
#!/usr/bin/env bash -l
set -e
###
# Add the line below to your setup command in Project Settings
#
# wget https://gist.githubusercontent.com/mimimalizam/27959bbc653de3965bb40955f4bc43df/raw/pg-downgrade-semaphore.sh && bash pg-downgrade-semaphore.sh
#
# Note: reset your dependency cache in Project Settings > Admin, before running this script
###
pg_version=${1:-'9.4'}
echo "--------------------------------------------"
echo "# Installing PostgreSQL version: $pg_version"
echo "--------------------------------------------"
install-package --update libpq5 postgresql-client-$pg_version postgresql-$pg_version postgresql-contrib-$pg_version postgresql-server-dev-$pg_version libpq-dev postgresql-$pg_version-postgis-2.2
echo 'allow_system_table_mods = on' | sudo tee -a /etc/postgresql/10/main/postgresql.conf
sudo service postgresql restart
echo "Creating postgres user"
sudo su postgres <<CMD
declare -x PGCLUSTER="9.4/main"
psql -c "ALTER USER postgres" -d template1;
psql -c "CREATE USER runner WITH PASSWORD 'semaphoredb';" -d template1;
psql -c "ALTER USER runner CREATEUSER CREATEDB;" -d template1;
psql -c "CREATE EXTENSION hstore WITH SCHEMA pg_catalog;" -d template1;
CMD
export PGCLUSTER="9.4/main"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment