refactor(dbt): migrate to domain-scoped schema names
Some checks failed
CI / lint-and-test (pull_request) Has been cancelled

- Create generate_schema_name macro to use custom schema names directly
- Update dbt_project.yml schemas: staging→stg_toronto, intermediate→int_toronto, marts→mart_toronto
- Add dbt/macros/toronto/ directory for future domain-specific macros
- Fix documentation drift in PROJECT_REFERENCE.md (load-data-only→load-toronto-only)
- Update DATABASE_SCHEMA.md with new schema names
- Update CLAUDE.md database schemas table
- Update adding-dashboard.md runbook with domain-scoped pattern

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-02 12:32:39 -05:00
parent 56bcc1bb1d
commit cda2a078d9
7 changed files with 32 additions and 13 deletions

View File

@@ -122,9 +122,9 @@ erDiagram
|--------|---------|------------|
| `public` | Shared dimensions (dim_time) | SQLAlchemy |
| `raw_toronto` | Toronto dimension and fact tables | SQLAlchemy |
| `staging` | Staging models | dbt |
| `intermediate` | Intermediate models | dbt |
| `marts` | Analytical tables | dbt |
| `stg_toronto` | Toronto staging models | dbt |
| `int_toronto` | Toronto intermediate models | dbt |
| `mart_toronto` | Toronto analytical tables | dbt |
### Raw Toronto Schema (raw_toronto)
@@ -149,7 +149,7 @@ Shared dimensions used across all projects:
|-------|-------------|
| `dim_time` | Time dimension (monthly grain) |
### Staging Schema (dbt)
### Staging Schema - stg_toronto (dbt)
Staging models provide 1:1 cleaned representations of source data:
@@ -164,7 +164,7 @@ Staging models provide 1:1 cleaned representations of source data:
| `stg_dimensions__cmhc_zones` | raw.cmhc_zones | CMHC zone boundaries |
| `stg_cmhc__zone_crosswalk` | raw.crosswalk | Zone-neighbourhood mapping |
### Marts Schema (dbt)
### Marts Schema - mart_toronto (dbt)
Analytical tables ready for dashboard consumption:

View File

@@ -269,7 +269,7 @@ LOG_LEVEL=INFO
| `db-init` | Initialize database schema |
| `db-reset` | Drop and recreate database (DESTRUCTIVE) |
| `load-data` | Load Toronto data from APIs, seed dev data |
| `load-data-only` | Load Toronto data without dbt or seeding |
| `load-toronto-only` | Load Toronto data without dbt or seeding |
| `seed-data` | Seed sample development data |
| `run` | Start Dash dev server |
| `test` | Run pytest |

View File

@@ -103,7 +103,15 @@ models:
staging:
{dashboard_name}:
+materialized: view
+schema: staging
+schema: stg_{dashboard_name}
intermediate:
{dashboard_name}:
+materialized: view
+schema: int_{dashboard_name}
marts:
{dashboard_name}:
+materialized: table
+schema: mart_{dashboard_name}
```
Follow naming conventions: