5. Database
The project uses a single PostgreSQL database (import_db) for imported stop data, GTFS identity resolution, route comparison data, and problem rows.
The schema is disposable by design:
- migrations run in the
migratorcontainer - importer truncates the selected table scope
- current pipeline output is bulk-inserted
This keeps DB contents aligned with the latest output from matching_and_import_db/.
| Database | Env Var | Behavior | Contains |
|---|---|---|---|
Import DB (import_db) |
DATABASE_URI |
migration + scoped refresh on each import run | stop/identity tables, route source anchors, normalized route tables, route matches, and problems |
Active Schema
The active ORM schema ([backend/models.py](https://github.com/openTdataCH/stop_sync_osm_atlas/blob/main/backend/models.py)) is organized into five groups.
1. Stop and Identity
atlas_operatorsatlas_stopsgtfs_stops_rawgtfs_stop_identity_resolutionosm_nodesosm_stopsosm_stop_membersstops_matchedproblems
2. Route Source Anchors
atlas_line_familiesosm_route_relations
These are the only raw/source route tables still persisted. Legacy raw route detail tables are no longer part of the ORM schema.
3. Normalized Route Model
line_familiesitinerariesstop_calls
These tables are the route model consumed by the web application.
4. Route Match Results
line_family_matchesitinerary_matches
5. Relationship Summary
Refresh Modes
Importer refresh scope comes from matching_and_import_db/database/importer.py.
complete
Truncates and rewrites all import tables.
atlas_cached_bootstrap
Used when ATLAS and GTFS preprocessing artifacts are reusable but the required static import tables are missing or empty.
- truncates and rewrites the full import schema, like
complete - repopulates the static ATLAS/GTFS tables so later
atlas_cachedruns can reuse them
atlas_cached
Reuses ATLAS/GTFS static tables and rewrites dynamic tables.
Required static tables:
atlas_stopsgtfs_stops_rawgtfs_stop_identity_resolutionatlas_line_families
Rewritten dynamic tables:
osm_nodesosm_stopsosm_stop_membersstops_matchedproblemsosm_route_relationsline_familiesitinerariesstop_callsline_family_matchesitinerary_matches
See 7.4 Atlas-Cached Import Optimization for operational behavior.