Last active
March 5, 2019 15:16
-
-
Save ceicke/a24be7bc78ef7ec07139681e295f7d23 to your computer and use it in GitHub Desktop.
Downgrade PostgreSQL on Semaphore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 "# Removing currently installed PostgreSQL" | |
echo "--------------------------------------------" | |
sudo apt-get purge -y postgresql-client-* postgresql-* postgresql-contrib-* postgresql-server-dev-* libpq-dev | |
sudo apt-get update | |
echo "--------------------------------------------" | |
echo "# Installing PostgreSQL version: $pg_version" | |
echo "--------------------------------------------" | |
install-package 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 "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