finish local dev setup
check / flake-check (push) Successful in 35s
deploy / deploy (push) Successful in 39s

This commit is contained in:
Lars Nolden
2026-07-10 15:59:03 +02:00
parent 1047968946
commit f4b5926e1f
5 changed files with 638 additions and 16 deletions
+34 -5
View File
@@ -44,12 +44,41 @@ Write plain SQL. Conventions:
## Local dev
`nix run .#dev` starts a plain Postgres via process-compose; apply migrations
to it the same way:
`nix run .#dev` applies everything automatically: its `db-migrate` process
bootstraps the Supabase roles/schemas, runs `supabase db push`, and loads
`seed.sql` on every start (all idempotent — see
`nix/dev/process-compose.nix`). To re-apply by hand against the running dev
Postgres, do it as the local superuser (your OS user — `gebos_ingest` is only
*created* by the migration and has no DDL rights). The CLI ignores `sslmode`
in the URL, so TLS must be disabled via the environment:
```sh
supabase db push --db-url "postgres://gebos_ingest:dev@127.0.0.1:5432/gebos"
PGSSLMODE=disable supabase db push --db-url "postgres://$USER@127.0.0.1:5432/gebos"
```
(Note: the dev database has no TimescaleDB unless the process-compose postgres
gains the extension — `create_hypertable` calls will fail there until then.)
(The dev postgres ships TimescaleDB — the Apache edition, which covers
hypertables; TSL-only features like compression are absent locally.)
## Seed / fixture data (dev and tests only)
`seed.sql` fills the local database with a self-consistent fixture world:
2 buildings (gas / district heating), 8 apartments, tenants incl. a
Mieterwechsel and a vacancy, gateways, sensors (incl. one unassigned), ~13
months of daily cumulative measurements with realistic seasonality, and
approximate reference data (thresholds, CO2 factors, prices, HDD). The header
comment in the file documents every scenario and the fixed-UUID namespaces.
Apply it after the migrations, with a superuser (the seed writes tables the
`gebos_ingest` role may not):
```sh
psql -h 127.0.0.1 -p 5432 -d gebos -f supabase/seed.sql
```
It is idempotent (fixed UUIDs + `ON CONFLICT DO NOTHING`, deterministic
measurement generation) — re-running on a later day only appends the new
days of measurements.
**Never apply it to prod**: the tenants and devices are fake, and the
regulatory numbers are development approximations, not verified values from
the legal sources. Verified reference data belongs in its own migration.