Skip to content

Commit

Permalink
Directly read from the Tiamat database
Browse files Browse the repository at this point in the history
- Use the default database also as the metadata database
- Create a direct connection to the Tiamat database
- Track all public tables
- Track all relevant parent -> child connections
  • Loading branch information
culka committed Mar 20, 2024
1 parent bd3cfaf commit 145d49f
Show file tree
Hide file tree
Showing 102 changed files with 1,000 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,12 @@ Our Docker image expects the following secrets to be bound to the container:
| db-jore3importer-username | Name of the sql user that is used by the jore3 importer service |
| db-timetables-api-username | Name of the sql user that is used by the timetables API service |

Additionally, when using HSL schema, the following secrets should be bound:

| Secret file | Description |
| -------------- | ---------------------------------------------- |
| db-tiamat-name | Name of the logical database for stop registry |

### Use of the Docker image

The Docker image expects the following values for the following environment
Expand Down
15 changes: 15 additions & 0 deletions metadata/generic/databases/databases.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
- name: metadata
kind: postgres
configuration:
connection_info:
database_url:
from_env: HASURA_GRAPHQL_METADATA_DATABASE_URL
isolation_level: serializable
pool_settings:
connection_lifetime: 600
idle_timeout: 180
max_connections: 50
retries: 1
use_prepared_statements: true
tables: []
functions: []
- name: default
kind: postgres
configuration:
Expand Down
Empty file.
16 changes: 16 additions & 0 deletions metadata/hsl/databases/databases.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
- name: tiamatdb
kind: postgres
configuration:
connection_info:
database_url:
from_env: HASURA_TIAMAT_DATABASE_URL
isolation_level: read-committed
use_prepared_statements: false
customization:
naming_convention: hasura-default
root_fields:
namespace: stop_database
prefix: stop_database_
type_names:
prefix: stop_database_
tables: "!include tiamatdb/tables/tables.yaml"
35 changes: 35 additions & 0 deletions metadata/hsl/databases/tiamatdb/tables/public_access_space.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
table:
name: access_space
schema: public
object_relationships:
- name: accessibility_assessment
using:
foreign_key_constraint_on: accessibility_assessment_id
- name: installed_equipment_version_structure
using:
foreign_key_constraint_on: place_equipments_id
- name: persistable_polygon
using:
foreign_key_constraint_on: polygon_id
array_relationships:
- name: access_space_alternative_names
using:
foreign_key_constraint_on:
column: access_space_id
table:
name: access_space_alternative_names
schema: public
- name: access_space_equipment_places
using:
foreign_key_constraint_on:
column: access_space_id
table:
name: access_space_equipment_places
schema: public
- name: access_space_key_values
using:
foreign_key_constraint_on:
column: access_space_id
table:
name: access_space_key_values
schema: public
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
table:
name: access_space_alternative_names
schema: public
object_relationships:
- name: alternative_name
using:
foreign_key_constraint_on: alternative_names_id
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
table:
name: access_space_check_constraints
schema: public
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
table:
name: access_space_equipment_places
schema: public
object_relationships:
- name: equipment_place
using:
foreign_key_constraint_on: equipment_places_id
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
table:
name: access_space_key_values
schema: public
object_relationships:
- name: value
using:
foreign_key_constraint_on: key_values_id
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
table:
name: accessibility_assessment
schema: public
array_relationships:
- name: accessibility_assessment_limitations
using:
foreign_key_constraint_on:
column: accessibility_assessment_id
table:
name: accessibility_assessment_limitations
schema: public
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
table:
name: accessibility_assessment_limitations
schema: public
object_relationships:
- name: accessibility_limitation
using:
foreign_key_constraint_on: limitations_id
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
table:
name: accessibility_limitation
schema: public
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
table:
name: alternative_name
schema: public
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
table:
name: boarding_position
schema: public
object_relationships:
- name: installed_equipment_version_structure
using:
foreign_key_constraint_on: place_equipments_id
- name: persistable_polygon
using:
foreign_key_constraint_on: polygon_id
array_relationships:
- name: boarding_position_alternative_names
using:
foreign_key_constraint_on:
column: boarding_position_id
table:
name: boarding_position_alternative_names
schema: public
- name: boarding_position_equipment_places
using:
foreign_key_constraint_on:
column: boarding_position_id
table:
name: boarding_position_equipment_places
schema: public
- name: boarding_position_key_values
using:
foreign_key_constraint_on:
column: boarding_position_id
table:
name: boarding_position_key_values
schema: public
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
table:
name: boarding_position_alternative_names
schema: public
object_relationships:
- name: alternative_name
using:
foreign_key_constraint_on: alternative_names_id
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
table:
name: boarding_position_check_constraints
schema: public
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
table:
name: boarding_position_equipment_places
schema: public
object_relationships:
- name: equipment_place
using:
foreign_key_constraint_on: equipment_places_id
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
table:
name: boarding_position_key_values
schema: public
object_relationships:
- name: value
using:
foreign_key_constraint_on: key_values_id
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
table:
name: check_constraint
schema: public
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
table:
name: check_constraint_key_values
schema: public
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
table:
name: destination_display_view
schema: public
22 changes: 22 additions & 0 deletions metadata/hsl/databases/tiamatdb/tables/public_equipment_place.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
table:
name: equipment_place
schema: public
object_relationships:
- name: persistable_polygon
using:
foreign_key_constraint_on: polygon_id
array_relationships:
- name: equipment_place_equipment_positions
using:
foreign_key_constraint_on:
column: equipment_place_id
table:
name: equipment_place_equipment_positions
schema: public
- name: equipment_place_key_values
using:
foreign_key_constraint_on:
column: equipment_place_id
table:
name: equipment_place_key_values
schema: public
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
table:
name: equipment_place_equipment_positions
schema: public
object_relationships:
- name: equipment_position
using:
foreign_key_constraint_on: equipment_positions_id
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
table:
name: equipment_place_key_values
schema: public
object_relationships:
- name: value
using:
foreign_key_constraint_on: key_values_id
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
table:
name: equipment_position
schema: public
object_relationships:
- name: multilingual_string_entity
using:
foreign_key_constraint_on: description_id
array_relationships:
- name: equipment_position_key_values
using:
foreign_key_constraint_on:
column: equipment_position_id
table:
name: equipment_position_key_values
schema: public
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
table:
name: equipment_position_key_values
schema: public
object_relationships:
- name: value
using:
foreign_key_constraint_on: key_values_id
3 changes: 3 additions & 0 deletions metadata/hsl/databases/tiamatdb/tables/public_export_job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
table:
name: export_job
schema: public
29 changes: 29 additions & 0 deletions metadata/hsl/databases/tiamatdb/tables/public_fare_zone.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
table:
name: fare_zone
schema: public
object_relationships:
- name: persistable_polygon
using:
foreign_key_constraint_on: polygon_id
array_relationships:
- name: fare_zone_key_values
using:
foreign_key_constraint_on:
column: fare_zone_id
table:
name: fare_zone_key_values
schema: public
- name: fare_zone_members
using:
foreign_key_constraint_on:
column: fare_zone_id
table:
name: fare_zone_members
schema: public
- name: fare_zone_neighbours
using:
foreign_key_constraint_on:
column: fare_zone_id
table:
name: fare_zone_neighbours
schema: public
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
table:
name: fare_zone_key_values
schema: public
object_relationships:
- name: value
using:
foreign_key_constraint_on: key_values_id
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
table:
name: fare_zone_members
schema: public
object_relationships:
- name: fare_zone
using:
foreign_key_constraint_on: fare_zone_id
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
table:
name: fare_zone_neighbours
schema: public
object_relationships:
- name: fare_zone
using:
foreign_key_constraint_on: fare_zone_id
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
table:
name: geography_columns
schema: public
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
table:
name: geometry_columns
schema: public
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
table:
name: group_of_stop_places
schema: public
array_relationships:
- name: group_of_stop_places_alternative_names
using:
foreign_key_constraint_on:
column: group_of_stop_places_id
table:
name: group_of_stop_places_alternative_names
schema: public
- name: group_of_stop_places_key_values
using:
foreign_key_constraint_on:
column: group_of_stop_places_id
table:
name: group_of_stop_places_key_values
schema: public
- name: group_of_stop_places_members
using:
foreign_key_constraint_on:
column: group_of_stop_places_id
table:
name: group_of_stop_places_members
schema: public
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
table:
name: group_of_stop_places_alternative_names
schema: public
object_relationships:
- name: alternative_name
using:
foreign_key_constraint_on: alternative_names_id
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
table:
name: group_of_stop_places_key_values
schema: public
object_relationships:
- name: value
using:
foreign_key_constraint_on: key_values_id
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
table:
name: group_of_stop_places_members
schema: public
Loading

0 comments on commit 145d49f

Please sign in to comment.