File tree Expand file tree Collapse file tree 8 files changed +71
-101
lines changed
Expand file tree Collapse file tree 8 files changed +71
-101
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ ENV LANG fi_FI.utf8
88# download script for reading docker secrets
99ADD https://raw.githubusercontent.com/HSLdevcom/jore4-tools/main/docker/read-secrets.sh /jore4/scripts/read-secrets.sh
1010
11- COPY 00-initialize.sql /jore4/migrations/00-initialize.sql
11+ COPY migrations/ /jore4/migrations/
1212COPY replace-placeholders-in-sql-schema-migrations.sh /jore4/scripts/replace-placeholders-in-sql-schema-migrations.sh
1313
1414COPY docker-entrypoint.sh /jore4/scripts/
Original file line number Diff line number Diff line change 1+ -- These database roles are also created in the azure-infra-jore4aks (Azure
2+ -- DevOps) repository.
3+ CREATE USER xxx_db_auth_username_xxx PASSWORD ' xxx_db_auth_password_xxx' ;
4+ CREATE USER xxx_db_jore3importer_username_xxx PASSWORD ' xxx_db_jore3importer_password_xxx' ;
5+ CREATE USER xxx_db_hasura_username_xxx PASSWORD ' xxx_db_hasura_password_xxx' ;
6+ CREATE USER xxx_db_tiamat_username_xxx PASSWORD ' xxx_db_tiamat_password_xxx' ;
7+ CREATE USER xxx_db_timetables_api_username_xxx PASSWORD ' xxx_db_timetables_api_password_xxx' ;
8+
9+ -- Make the hasura role a member of jore3importer role because both roles must
10+ -- have ownership of tables and sequences in the default database (network and
11+ -- routes) since both are responsible for populating and truncating tables in
12+ -- the aforementioned database. In particular, sequence reset requires an
13+ -- ownership and cannot be granted as a privilege.
14+ GRANT xxx_db_jore3importer_username_xxx TO xxx_db_hasura_username_xxx;
Original file line number Diff line number Diff line change 1+ -- Create the extensions used, see https://hasura.io/docs/latest/graphql/core/deployment/postgres-requirements.html
2+ -- Create the extensions in the public schema, since we'd need to give additional privileges ("use schema") to any
3+ -- user who wishes to use these in the future. Also, Hasura would require additional setup to be able to use the
4+ -- extensions from another schema.
5+ CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA public;
6+ CREATE EXTENSION IF NOT EXISTS postgis WITH SCHEMA public;
7+ CREATE EXTENSION IF NOT EXISTS btree_gist WITH SCHEMA public;
8+
9+ -- Allow Hasura to create new schemas.
10+ GRANT CREATE ON DATABASE xxx_db_hasura_name_xxx TO xxx_db_hasura_username_xxx;
Original file line number Diff line number Diff line change 1+ -- Create database and give ALL privileges to the auth user.
2+ CREATE DATABASE xxx_db_auth_name_xxx ;
3+ GRANT ALL ON DATABASE xxx_db_auth_name_xxx TO xxx_db_auth_username_xxx;
Original file line number Diff line number Diff line change 1+ -- Create database and give ALL privileges to the jore3importer user.
2+ CREATE DATABASE xxx_db_jore3importer_name_xxx ;
3+ GRANT ALL ON DATABASE xxx_db_jore3importer_name_xxx TO xxx_db_jore3importer_username_xxx;
Original file line number Diff line number Diff line change 1+ -- Create database and allow Hasura to create new schemas in it.
2+ CREATE DATABASE xxx_db_timetables_name_xxx ;
3+ GRANT CREATE ON DATABASE xxx_db_timetables_name_xxx TO xxx_db_hasura_username_xxx;
4+
5+ -- Interval outputs by default are using the sql format ('3 4:05:06'). Here we
6+ -- are switching to ISO 8601 format ('P3DT4H5M6S').
7+ ALTER DATABASE xxx_db_timetables_name_xxx SET intervalstyle = ' iso_8601' ;
8+
9+ -- Switch database context to be able to add extensions there.
10+ \connect xxx_db_timetables_name_xxx;
11+
12+ CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA public;
13+ CREATE EXTENSION IF NOT EXISTS btree_gist WITH SCHEMA public;
Original file line number Diff line number Diff line change 1+ -- Create database and give ALL privileges to Tiamat in it.
2+ CREATE DATABASE xxx_db_tiamat_name_xxx ;
3+ GRANT ALL ON DATABASE xxx_db_tiamat_name_xxx TO xxx_db_tiamat_username_xxx;
4+
5+ -- Switch database context to initialise it to the state where Tiamat can use
6+ -- it.
7+ \connect xxx_db_tiamat_name_xxx;
8+
9+ CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA public;
10+ CREATE EXTENSION IF NOT EXISTS postgis WITH SCHEMA public;
11+
12+ CREATE SCHEMA IF NOT EXISTS topology AUTHORIZATION xxx_db_tiamat_username_xxx;
13+ CREATE EXTENSION IF NOT EXISTS postgis_topology WITH SCHEMA topology;
14+ -- The postgis_topology creates two tables.
15+ ALTER TABLE topology .layer OWNER TO xxx_db_tiamat_username_xxx;
16+ ALTER TABLE topology .topology OWNER TO xxx_db_tiamat_username_xxx;
17+
18+ -- Grant Hasura read permissions to the stop registry database.
19+ GRANT CONNECT ON DATABASE xxx_db_tiamat_name_xxx TO xxx_db_hasura_username_xxx;
20+
21+ GRANT USAGE 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+ ALTER DEFAULT PRIVILEGES FOR USER xxx_db_tiamat_username_xxx IN SCHEMA public GRANT SELECT ON TABLES TO xxx_db_hasura_username_xxx;
24+
25+ GRANT USAGE ON SCHEMA topology TO xxx_db_hasura_username_xxx;
26+ GRANT SELECT ON ALL TABLES IN SCHEMA topology TO xxx_db_hasura_username_xxx;
27+ ALTER DEFAULT PRIVILEGES FOR USER xxx_db_tiamat_username_xxx IN SCHEMA topology GRANT SELECT ON TABLES TO xxx_db_hasura_username_xxx;
You can’t perform that action at this time.
0 commit comments