Erd
Generating Mermaid ERD...
erDiagram
audit_documents {
VARCHAR change_reason
VARCHAR change_type
DATETIME changed_at
INTEGER changed_by
VARCHAR current_hash
JSON data_diff
JSON data_snapshot
INTEGER entity_id "indexed"
VARCHAR entity_type "indexed"
JSON handled_ids
VARCHAR handler_id
INTEGER id PK
VARCHAR ip_address
BOOLEAN is_current
VARCHAR previous_hash
VARCHAR route_path
JSON route_payload
VARCHAR sync_error
VARCHAR sync_status
DATETIME synced_at
INTEGER version "indexed"
}
auth_exchange_code {
VARCHAR code PK
DATETIME consumed_at
DATETIME created_at
DATETIME expires_at
INTEGER user_id FK
}
building_rooms {
VARCHAR building_location "indexed"
VARCHAR building_name "indexed"
INTEGER id PK
VARCHAR room_name "indexed"
FLOAT room_surface_square_meter
VARCHAR room_type
}
carbon_projects {
VARCHAR carbon_report_type
INTEGER end_year "indexed"
INTEGER id PK
BOOLEAN is_viewable_by_unit_members
VARCHAR name "indexed"
INTEGER start_year "indexed"
INTEGER unit_id FK
}
carbon_report_modules {
INTEGER carbon_report_id FK
INTEGER id PK
INTEGER last_updated
INTEGER module_type_id "indexed"
JSON stats
INTEGER status "indexed"
}
carbon_reports {
INTEGER carbon_project_id FK
VARCHAR completion_progress
INTEGER id PK
INTEGER last_updated
INTEGER overall_status
INTEGER reference_year
JSON stats
INTEGER unit_id FK
INTEGER year
}
data_entries {
INTEGER carbon_report_module_id FK
DATETIME created_at
INTEGER created_by_id "indexed"
JSON data
INTEGER data_entry_type_id "indexed"
INTEGER id PK
INTEGER source "indexed"
VARCHAR status
INTEGER unit_id "indexed"
DATETIME updated_at
INTEGER year "indexed"
}
data_entry_emissions {
FLOAT additional_value "Polymorphic physical quantity tied to this emission row. Unit is inferred from emission_type_id (e.g. km for commuting and travel, kg for food and waste)."
TIMESTAMP computed_at "indexed"
INTEGER data_entry_id FK
INTEGER emission_type_id "indexed"
INTEGER id PK
FLOAT kg_co2eq
JSON meta
INTEGER primary_factor_id FK
INTEGER scope
}
data_ingestion_jobs {
INTEGER attempts
INTEGER data_entry_type_id "indexed"
INTEGER entity_id
VARCHAR entity_type
DATETIME finished_at
INTEGER id PK
VARCHAR ingestion_method "indexed"
BOOLEAN is_current
VARCHAR job_type
DATETIME locked_at
VARCHAR locked_by
INTEGER max_attempts
JSON meta
INTEGER module_type_id "indexed"
UUID pipeline_id FK
VARCHAR provider
VARCHAR result
DATETIME run_after "indexed"
DATETIME started_at
VARCHAR state
VARCHAR status_message
VARCHAR target_type "indexed"
INTEGER year "indexed"
}
factors {
JSON classification
INTEGER data_entry_type_id "indexed"
INTEGER emission_type_id "indexed"
INTEGER id PK
INTEGER last_seen_job_id FK
JSON values
INTEGER year "indexed"
}
locations {
VARCHAR airport_size
VARCHAR continent "indexed"
VARCHAR country_code "indexed"
VARCHAR iata_code "indexed"
INTEGER id PK
VARCHAR keywords "indexed"
FLOAT latitude
FLOAT longitude
VARCHAR municipality "indexed"
VARCHAR name "indexed"
VARCHAR natural_key "indexed"
VARCHAR transport_mode "indexed"
}
pipelines {
DATETIME created_at
INTEGER entity_type
INTEGER error_count
INTEGER expected_recalc
DATETIME finished_at
UUID id PK
INTEGER ingestion_method
INTEGER job_count
VARCHAR kind
VARCHAR last_error
INTEGER module_type_id "indexed"
DATETIME started_at
VARCHAR status "indexed"
DATETIME updated_at
INTEGER year "indexed"
}
pods {
VARCHAR app_version
VARCHAR git_sha
DATETIME last_heartbeat_at
VARCHAR pod_id PK
DATETIME started_at
}
unit_users {
VARCHAR role "indexed"
INTEGER unit_id PK
INTEGER user_id PK
}
units {
INTEGER id PK
VARCHAR institutional_code "indexed"
VARCHAR institutional_id "indexed"
BOOLEAN is_active
VARCHAR label_en
VARCHAR label_fr
INTEGER level "indexed"
VARCHAR name "indexed"
VARCHAR parent_institutional_code "indexed"
VARCHAR parent_institutional_id
VARCHAR path_institutional_code "indexed"
VARCHAR path_institutional_id
VARCHAR path_name
VARCHAR principal_user_institutional_id "indexed"
VARCHAR provider
INTEGER unit_type_id
VARCHAR unit_type_label
}
users {
VARCHAR display_name
VARCHAR email "indexed"
VARCHAR function
INTEGER id PK
VARCHAR institutional_id "indexed"
DATETIME last_login
DATETIME last_roles_sync_at
VARCHAR provider
JSON roles_raw
}
year_configuration {
JSON config
DATETIME configuration_completed
BOOLEAN is_started
VARCHAR provider PK
DATETIME updated_at
INTEGER year PK
}
carbon_projects ||--}o carbon_reports : "carbon_project_id"
carbon_report_modules ||--}o data_entries : "carbon_report_module_id"
carbon_reports ||--}o carbon_report_modules : "carbon_report_id"
data_entries ||--}o data_entry_emissions : "data_entry_id"
data_ingestion_jobs ||--}o factors : "last_seen_job_id"
factors ||--}o data_entry_emissions : "primary_factor_id"
pipelines ||--}o data_ingestion_jobs : "pipeline_id"
units ||--}o carbon_projects : "unit_id"
units ||--}o carbon_reports : "unit_id"
units ||--}o unit_users : "unit_id"
users ||--}o auth_exchange_code : "user_id"
users ||--}o unit_users : "user_id" Mermaid ERD generation complete.