From e54e2b7c56d2c367fd62ad1790be3c52e7e19fa4 Mon Sep 17 00:00:00 2001 From: david kiania Date: Mon, 15 Jun 2026 23:54:43 +0300 Subject: [PATCH] feat: drop constant service_type column (migration 07) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- README.md | 1 + migrations/07_inc_drop_service_type.sql | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 migrations/07_inc_drop_service_type.sql diff --git a/README.md b/README.md index e036c8b..8c8ad6c 100644 --- a/README.md +++ b/README.md @@ -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/.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) | diff --git a/migrations/07_inc_drop_service_type.sql b/migrations/07_inc_drop_service_type.sql new file mode 100644 index 0000000..1e4775e --- /dev/null +++ b/migrations/07_inc_drop_service_type.sql @@ -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;