Skip to content

Commit 0025272

Browse files
committed
Update PostGIS base Docker image for Azure mock database: 12-3.1 -> 15-3.5
In PostgreSQL 15, full schema privileges must be separately granted to users performing database migrations. Make the JORE4 administrator role the owner of the public schema for all databases. In PostgreSQL 12, this was the default.
1 parent 946a438 commit 0025272

File tree

6 files changed

+56
-5
lines changed

6 files changed

+56
-5
lines changed

azuredbmock/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Builder docker image.
2-
FROM postgis/postgis:12-3.1
1+
# base Docker image
2+
FROM postgis/postgis:15-3.5
33

44
# fix collations to use fi_FI
55
RUN localedef -i fi_FI -c -f UTF-8 -A /usr/share/locale/locale.alias fi_FI.UTF-8

azuredbmock/migrations/02-create-network-database.sql

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
-- Make the JORE4 admin user the owner of the public schema.
2+
ALTER SCHEMA public OWNER TO CURRENT_USER;
3+
14
-- Create the extensions used, see https://hasura.io/docs/latest/graphql/core/deployment/postgres-requirements.html
25
-- Create the extensions in the public schema, since we'd need to give additional privileges ("use schema") to any
36
-- user who wishes to use these in the future. Also, Hasura would require additional setup to be able to use the
@@ -8,3 +11,13 @@ CREATE EXTENSION IF NOT EXISTS btree_gist WITH SCHEMA public;
811

912
-- Allow Hasura to create new schemas.
1013
GRANT CREATE ON DATABASE xxx_db_hasura_name_xxx TO xxx_db_hasura_username_xxx;
14+
15+
-- Grant select permissions on information_schema and pg_catalog to the Hasura
16+
-- user.
17+
GRANT SELECT ON ALL TABLES IN SCHEMA information_schema TO xxx_db_hasura_username_xxx;
18+
GRANT SELECT ON ALL TABLES IN SCHEMA pg_catalog TO xxx_db_hasura_username_xxx;
19+
20+
-- Grant required privileges in the public schema to the Hasura user.
21+
GRANT ALL ON SCHEMA public TO xxx_db_hasura_username_xxx;
22+
GRANT SELECT ON ALL TABLES IN SCHEMA public TO xxx_db_hasura_username_xxx;
23+
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO xxx_db_hasura_username_xxx;
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1-
-- Create database and give ALL privileges to the auth user.
1+
-- Create database and allow the auth user to create new schemas in it.
22
CREATE DATABASE xxx_db_auth_name_xxx;
33
GRANT ALL ON DATABASE xxx_db_auth_name_xxx TO xxx_db_auth_username_xxx;
4+
5+
\connect xxx_db_auth_name_xxx;
6+
7+
-- Make the JORE4 admin user the owner of the public schema.
8+
ALTER SCHEMA public OWNER TO CURRENT_USER;
9+
10+
-- Grant full schema access to the public schema to the auth user.
11+
GRANT ALL ON SCHEMA public TO xxx_db_auth_username_xxx;
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1-
-- Create database and give ALL privileges to the jore3importer user.
1+
-- Create database and allow the jore3importer user to create new schemas in it.
22
CREATE DATABASE xxx_db_jore3importer_name_xxx;
33
GRANT ALL ON DATABASE xxx_db_jore3importer_name_xxx TO xxx_db_jore3importer_username_xxx;
4+
5+
\connect xxx_db_jore3importer_name_xxx;
6+
7+
-- Make the JORE4 admin user the owner of the public schema.
8+
ALTER SCHEMA public OWNER TO CURRENT_USER;
9+
10+
-- Grant privileges in the public schema to the jore3importer user.
11+
GRANT USAGE ON SCHEMA public TO xxx_db_jore3importer_username_xxx;
12+
GRANT SELECT ON ALL TABLES IN SCHEMA public TO xxx_db_jore3importer_username_xxx;
13+
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO xxx_db_jore3importer_username_xxx;

azuredbmock/migrations/05-create-timetables-database.sql

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,17 @@ ALTER DATABASE xxx_db_timetables_name_xxx SET intervalstyle = 'iso_8601';
99
-- Switch database context to be able to add extensions there.
1010
\connect xxx_db_timetables_name_xxx;
1111

12+
-- Make the JORE4 admin user the owner of the public schema.
13+
ALTER SCHEMA public OWNER TO CURRENT_USER;
14+
1215
CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA public;
1316
CREATE EXTENSION IF NOT EXISTS btree_gist WITH SCHEMA public;
17+
18+
-- Grant select permissions on information_schema and pg_catalog to Hasura.
19+
GRANT SELECT ON ALL TABLES IN SCHEMA information_schema TO xxx_db_hasura_username_xxx;
20+
GRANT SELECT ON ALL TABLES IN SCHEMA pg_catalog TO xxx_db_hasura_username_xxx;
21+
22+
-- Grant required privileges in the public schema to Hasura.
23+
GRANT ALL ON SCHEMA public TO xxx_db_hasura_username_xxx;
24+
GRANT SELECT ON ALL TABLES IN SCHEMA public TO xxx_db_hasura_username_xxx;
25+
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO xxx_db_hasura_username_xxx;

azuredbmock/migrations/06-create-stopregistry-database.sql

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
1-
-- Create database and give ALL privileges to Tiamat in it.
1+
-- Create database and allow Tiamat to create new schemas in it.
22
CREATE DATABASE xxx_db_tiamat_name_xxx;
33
GRANT ALL ON DATABASE xxx_db_tiamat_name_xxx TO xxx_db_tiamat_username_xxx;
44

55
-- Switch database context to initialise it to the state where Tiamat can use
66
-- it.
77
\connect xxx_db_tiamat_name_xxx;
88

9+
-- Make the JORE4 admin user the owner of the public schema.
10+
ALTER SCHEMA public OWNER TO CURRENT_USER;
11+
912
CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA public;
1013
CREATE EXTENSION IF NOT EXISTS postgis WITH SCHEMA public;
1114

15+
-- Grant required privileges in the public schema to Tiamat.
16+
GRANT ALL ON SCHEMA public TO xxx_db_tiamat_username_xxx;
17+
GRANT SELECT ON ALL TABLES IN SCHEMA public TO xxx_db_tiamat_username_xxx;
18+
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO xxx_db_tiamat_username_xxx;
19+
1220
CREATE SCHEMA IF NOT EXISTS topology AUTHORIZATION xxx_db_tiamat_username_xxx;
1321
CREATE EXTENSION IF NOT EXISTS postgis_topology WITH SCHEMA topology;
1422
-- The postgis_topology creates two tables.

0 commit comments

Comments
 (0)