Skip to content

Commit

Permalink
#9717 support Postgres versions 14 and 15
Browse files Browse the repository at this point in the history
  • Loading branch information
Don Sizemore committed Sep 5, 2023
1 parent ed81893 commit 53b8f93
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
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
23 changes: 19 additions & 4 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,6 +411,8 @@
else:
sys.exit("Couldn't create database or database already exists.\n")

# 3e. set permissions:

conn_cmd = "GRANT ALL PRIVILEGES on DATABASE "+pgDb+" to "+pgUser+";"
try:
cur.execute(conn_cmd)
Expand All @@ -418,6 +421,18 @@
cur.close()
conn.close()

if int(pg_major_version) >= 15:
conn_cmd = "GRANT ALL ON SCHEMA public TO "+pgUser+";"
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 53b8f93

Please sign in to comment.