feat: drop constant service_type column (migration 07)

service_type is always 'inc' (cardinality 1) — zero info, redundant in an INC-only
table. Drop the generated column; stays in raw for audit.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
david kiania 2026-06-15 23:54:43 +03:00
parent b86c0b2d13
commit e54e2b7c56
2 changed files with 11 additions and 0 deletions

View file

@ -17,6 +17,7 @@ Field-ops **INC ticket** ingestion, geocoding, and read-schema that powers the
| `migrations/04_inc_latlng.sql` | Redefines `latitude`/`longitude` to `COALESCE(feed, ST_Y/ST_X(geom))` so they're **populated from the geocoded position** (feed is always empty); precision per `geo_source` (`location` vs `cluster` centroid) |
| `migrations/05_inc_geography.sql` | Adds `geog geography(Point,4326)` (= `geom::geography`) + GiST index for **routing**`ST_Distance`/`ST_DWithin`/KNN in real metres (nearest-vehicle, radius search) |
| `migrations/06_inc_mttr_minutes.sql` | `mttr` generated column → integer **minutes** (source is decimal hours); drops the constant `is_alarm`/`is_auto_created`/`is_auto_closed` columns (kept in `raw`). `is_actionable` retained |
| `migrations/07_inc_drop_service_type.sql` | Drops the constant `service_type` column (always `inc`; kept in `raw`) |
| `import_tickets.py` | Ingests the **newest INC CSV** from the rustfs `tickets` bucket (`automations/inc/<EAT-timestamp>.csv`) and upserts on `ticket_id`; geocodes clusters + INC locations |
| `run_migrations.py` | Applies `migrations/*.sql` in order (ledger: `tickets.schema_migrations`) |
| `shared.py` | Minimal DB/logging helpers (self-contained — no tracksolid dependency) |

View file

@ -0,0 +1,10 @@
-- 07_inc_drop_service_type.sql — fleettickets · drop constant service_type column
-- ─────────────────────────────────────────────────────────────────────────────
-- service_type is always 'inc' in tickets.inc (cardinality 1) — zero information,
-- redundant since the table itself is the INC dataset. Drop the generated column;
-- it stays in `raw` for audit. Idempotent.
-- ─────────────────────────────────────────────────────────────────────────────
SET search_path = tickets, public;
ALTER TABLE tickets.inc DROP COLUMN IF EXISTS service_type;