Skip to content

Commit

Permalink
deps: Upgrade to PG 15
Browse files Browse the repository at this point in the history
  • Loading branch information
Betree committed Dec 10, 2024
1 parent 8130b8b commit cd8110c
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 45 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ jobs:
run: npm run build

test:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04

timeout-minutes: 30

Expand All @@ -209,7 +209,7 @@ jobs:
- 6379:6379
options: --entrypoint redis-server
postgres:
image: postgres:14.15
image: postgres:15.10
env:
POSTGRES_USER: postgres
POSTGRES_DB: postgres
Expand Down Expand Up @@ -251,7 +251,7 @@ jobs:
flags: Unit

test-graphql:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
timeout-minutes: 30

services:
Expand All @@ -261,7 +261,7 @@ jobs:
- 6379:6379
options: --entrypoint redis-server
postgres:
image: postgres:14.15
image: postgres:15.10
env:
POSTGRES_USER: postgres
POSTGRES_DB: postgres
Expand Down Expand Up @@ -324,7 +324,7 @@ jobs:
- 6379:6379
options: --entrypoint redis-server
postgres:
image: postgres:14.15
image: postgres:15.10
env:
POSTGRES_USER: postgres
POSTGRES_DB: postgres
Expand Down Expand Up @@ -366,7 +366,7 @@ jobs:
- 6379:6379
options: --entrypoint redis-server
postgres:
image: postgres:14.15
image: postgres:15.10
env:
POSTGRES_USER: postgres
POSTGRES_DB: postgres
Expand Down
23 changes: 12 additions & 11 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ env:

E2E_TEST: 1
PGHOST: localhost
PGUSER: postgres
PGUSER: opencollective
CYPRESS_RECORD: false
CYPRESS_VIDEO: false
CYPRESS_VIDEO_UPLOAD_ON_PASSES: false
Expand All @@ -34,7 +34,7 @@ env:

jobs:
e2e:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
timeout-minutes: 30

strategy:
Expand All @@ -48,7 +48,7 @@ jobs:
- 6379:6379
options: --entrypoint redis-server
postgres:
image: postgres:14.15
image: postgres:15.10
env:
POSTGRES_USER: postgres
POSTGRES_DB: postgres
Expand All @@ -62,14 +62,15 @@ jobs:
- name: Update apt
run: sudo apt-get update || exit 0

- name: Install Cypress dependencies
run: sudo apt-get install --no-install-recommends -y libgtk2.0-0 libgtk-3-0 libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb fonts-arphic-bkai00mp fonts-arphic-bsmi00lp fonts-arphic-gbsn00lp fonts-arphic-gkai00mp fonts-arphic-ukai fonts-arphic-uming ttf-wqy-zenhei ttf-wqy-microhei xfonts-wqy

- name: Install postgresql-client
run: sudo apt-get install -y postgresql-client

- name: Install graphicsmagick
run: sudo apt-get install -y graphicsmagick
- name: Install dependencies
run: |
sudo apt-get install \
`# Cypress dependencies - see https://docs.cypress.io/app/get-started/install-cypress#UbuntuDebian` \
libgtk2.0-0t64 libgtk-3-0t64 libgbm-dev libnotify-dev libnss3 libxss1 libasound2t64 libxtst6 xauth xvfb \
`# Postgres client` \
postgresql-client-16 \
`# GraphicsMagick (not sure if needed)` \
graphicsmagick
- name: Install stripe-cli
run: |
Expand Down
4 changes: 2 additions & 2 deletions docs/postgres.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PostgreSQL Database

You need to have PostgreSQL > 14.x.
You need to have PostgreSQL > 15.x.

In production, we're currently running 16.4.

Expand Down Expand Up @@ -57,7 +57,7 @@ If you don't want to run a local instance of PostgreSQL in your computer, you ca
Create and run the container:

```
docker run -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust -d --name opencollective-postgres --shm-size=1g --memory=4g --cpus=2 postgres:14
docker run -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust -d --name opencollective-postgres --shm-size=1g --memory=4g --cpus=2 postgres:15
```

Set the necessary environment variables:
Expand Down
52 changes: 26 additions & 26 deletions scripts/db_restore.sh
Original file line number Diff line number Diff line change
@@ -1,48 +1,47 @@
#!/bin/bash

usage() {
echo "Usage: db_restore.sh -d DBNAME -U DBUSER --use-postgis -f DBDUMP_FILE";
echo "e.g.";
echo "Usage: db_restore.sh -d DBNAME -U DBUSER --use-postgis -f DBDUMP_FILE"
echo "e.g."
echo "> db_restore.sh -d opencollective_dvl -U opencollective -f test/dbdumps/opencollective_dvl.pgsql"
exit 0;
exit 0
}

while [[ $# -gt 0 ]]
do
key="$1"
while [[ $# -gt 0 ]]; do
key="$1"

case $key in
-d|--dbname)
case $key in
-d | --dbname)
LOCALDBNAME="$2"
shift # past argument
;;
-U|--username)
-U | --username)
LOCALDBUSER="$2"
shift # past argument
;;
--use-postgis)
--use-postgis)
USE_POSTGIS=1
;;
-f|--file)
-f | --file)
DBDUMP_FILE="$2"
shift # past argument
;;
*)
# unknown option
*)
# unknown option
;;
esac
shift # past argument or value
esac
shift # past argument or value
done

LOCALDBUSER=${LOCALDBUSER:-"opencollective"}
LOCALDBNAME=${LOCALDBNAME:-"opencollective_dvl"}
DBDUMP_FILE=${DBDUMP_FILE:-"test/dbdumps/opencollective_dvl.pgsql"}
DBDUMP_FILE=${DBDUMP_FILE:-"./test/dbdumps/opencollective_dvl.pgsql"}

echo "LOCALDBUSER=$LOCALDBUSER"
echo "LOCALDBNAME=$LOCALDBNAME"
echo "DBDUMP_FILE=$DBDUMP_FILE"

if [ -z "$LOCALDBNAME" ]; then usage; fi;
if [ -z "$LOCALDBNAME" ]; then usage; fi

# kill all connections to the postgres server
# echo "Killing all connections to database '$LOCALDBNAME'"
Expand All @@ -53,8 +52,11 @@ if [ -z "$LOCALDBNAME" ]; then usage; fi;
# where pg_stat_activity.datname = '$LOCALDBNAME'
# EOF

dropdb -U postgres -h localhost --if-exists $LOCALDBNAME;
createdb -U postgres -h localhost $LOCALDBNAME 2> /dev/null
echo "Dropping '$LOCALDBNAME'"
dropdb -U postgres -h localhost --if-exists $LOCALDBNAME

echo "Creating '$LOCALDBNAME'"
createdb -U postgres -h localhost $LOCALDBNAME 2>/dev/null

# When restoring old backups, you may need to enable Postgis
if [ "$USE_POSTGIS" = "1" ]; then
Expand All @@ -72,16 +74,14 @@ fi
set -e
} | tee >/dev/null

# Update table permissions
echo "Updating table permissions"
psql -U postgres -h localhost $LOCALDBNAME -c "GRANT ALL ON SCHEMA public TO ${LOCALDBUSER};"

# The first time we run it, we will trigger FK constraints errors
set +e
pg_restore -U postgres -h localhost --no-acl --no-owner --role=${LOCALDBUSER} -n public -O -c -d "${LOCALDBNAME}" "${DBDUMP_FILE}" 2>/dev/null
set -e

# So we run it twice :-)
# So we run it twice :-)
pg_restore -U postgres -h localhost --no-acl --no-owner --role=${LOCALDBUSER} -n public -O -c -d "${LOCALDBNAME}" "${DBDUMP_FILE}"

echo "DB restored to postgres://localhost/${LOCALDBNAME}"

# Note: I have to run after this script:
# $> psql opencollective_test -c "REASSIGN OWNED BY xdamman TO opencollective;"
# Because the views created by the CIS extension are not owned by the opencollective user
Binary file modified test/dbdumps/opencollective_dvl.pgsql
Binary file not shown.

0 comments on commit cd8110c

Please sign in to comment.