Skip to content

Commit

Permalink
Merge pull request #9877 from IQSS/9717_postgres_15
Browse files Browse the repository at this point in the history
support Postgres versions 14 and 15
  • Loading branch information
kcondon authored Sep 8, 2023
2 parents b2ac915 + f71274e commit 104166a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
6 changes: 5 additions & 1 deletion doc/sphinx-guides/source/installation/prerequisites.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,14 @@ Also note that Payara may utilize more than the default number of file descripto
PostgreSQL
----------

PostgreSQL 13 is recommended because it's the version we test against. Version 10 or higher is required because that's what's `supported by Flyway <https://documentation.red-gate.com/fd/postgresql-184127604.html>`_, which we use for database migrations.

You are welcome to experiment with newer versions of PostgreSQL, but please note that as of PostgreSQL 15, permissions have been restricted on the ``public`` schema (`release notes <https://www.postgresql.org/docs/release/15.0/>`_, `EDB blog post <https://www.enterprisedb.com/blog/new-public-schema-permissions-postgresql-15>`_, `Crunchy Data blog post <https://www.crunchydata.com/blog/be-ready-public-schema-changes-in-postgres-15>`_). The Dataverse installer has been updated to restore the old permissions, but this may not be a long term solution.

Installing PostgreSQL
=====================

The application has been tested with PostgreSQL versions up to 13 and version 10+ is required. We recommend installing the latest version that is available for your OS distribution. *For example*, to install PostgreSQL 13 under RHEL7/derivative::
*For example*, to install PostgreSQL 13 under RHEL7/derivative::

# yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# yum makecache fast
Expand Down
2 changes: 1 addition & 1 deletion modules/dataverse-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@

<!-- Major system components and dependencies -->
<payara.version>6.2023.8</payara.version>
<postgresql.version>42.5.1</postgresql.version>
<postgresql.version>42.6.0</postgresql.version>
<solr.version>9.3.0</solr.version>
<aws.version>1.12.290</aws.version>
<google.cloud.version>0.177.0</google.cloud.version>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<packaging.type>war</packaging.type>

<reload4j.version>1.2.18.4</reload4j.version>
<flyway.version>8.5.10</flyway.version>
<flyway.version>9.21.2</flyway.version>
<jhove.version>1.20.1</jhove.version>
<jacoco.version>0.8.7</jacoco.version>
<poi.version>5.2.1</poi.version>
Expand Down
26 changes: 21 additions & 5 deletions scripts/installer/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,12 +380,13 @@
print("Can't connect to PostgresQL as the admin user.\n")
sys.exit("Is the server running, have you adjusted pg_hba.conf, etc?")

# 3b. get the Postgres version (do we need it still?)
# 3b. get the Postgres version for new permissions model in versions 15+
try:
pg_full_version = conn.server_version
print("PostgresQL version: "+str(pg_full_version))
pg_full_version = str(conn.server_version)
pg_major_version = pg_full_version[0:2]
print("PostgreSQL version: "+pg_major_version)
except:
print("Warning: Couldn't determine PostgresQL version.")
print("Warning: Couldn't determine PostgreSQL version.")
conn.close()

# 3c. create role:
Expand All @@ -410,14 +411,29 @@
else:
sys.exit("Couldn't create database or database already exists.\n")

conn_cmd = "GRANT ALL PRIVILEGES on DATABASE "+pgDb+" to "+pgUser+";"
# 3e. set permissions:

conn_cmd = "GRANT CREATE PRIVILEGES on DATABASE "+pgDb+" to "+pgUser+";"
try:
cur.execute(conn_cmd)
except:
sys.exit("Couldn't grant privileges on "+pgDb+" to "+pgUser)
cur.close()
conn.close()

if int(pg_major_version) >= 15:
conn_cmd = "GRANT ALL ON SCHEMA public TO "+pgUser+";"
print("PostgreSQL 15 or higher detected. Running " + conn_cmd)
try:
cur.execute(conn_cmd)
except:
if force:
print("WARNING: failed to grant permissions on schema public - continuing, since the --force option was specified")
else:
sys.exit("Couldn't grant privileges on schema public to "+pgUser)
cur.close()
conn.close()

print("Database and role created!")
if pgOnly:
print("postgres-only setup complete.")
Expand Down

0 comments on commit 104166a

Please sign in to comment.