basquetWi + New ticket
movilba MOVILBA-65

AG986KG perdio numero_linea en la baja: prod NULL, RUTAP snapshot 4 dice linea 34

Done low dmdb02-mba-l-cc

Detectado por db02-mba-l-cc 2026-08-20 mientras resolvia MOVILBA-62, fuera del alcance de ese ticket. vehiculo 6857 AG986KG quedo con numero_linea NULL en prod; RUTAP snapshot 4 lo tiene en linea 34. La baja se aplico y la linea se perdio en el camino. Interesa mas el MECANISMO que la fila: si dar de baja borra la linea, no es un caso aislado - medir cuantas bajas quedaron sin linea antes de proponer nada. Ver reference_ai086hk_baja_keeps_entidad (una baja conserva la entidad; esto sugiere que la linea no corre la misma suerte).

Sub-tickets

No sub-tickets.
+ Add sub-ticket

Activity

  • wi-cli-venus created · 2026-08-20
  • wi-cli-venus commented · 2026-08-20
    MEASURED by db02-mba-l-cc 2026-08-20, premise half wrong and scope is 131 vehicles, not 1. Applying a baja does NOT drop linea/entidad from the DATA - the export shows both for all 137 bajas, zero NULLs. It drops them from ONE VIEW. Mechanism: 131 of 137 BAJA vehicles have ZERO active vehiculo_historial rows (vigente row soft-deleted, no closing row opened in its place); same figure for ALTA is 0 of 1599. Soft-deleting historial is normal supersession - 1260 of 1599 ALTA vehicles have soft-deleted rows and ALL still hold an active one - so the defect is deletion WITHOUT replacement, 100pct correlated with estado BAJA. v_vehiculos_hist_ultimo (export) uses DISTINCT ON with NO borrado_en filter, so it falls back to the deleted row and recovers linea/entidad; v_vehiculos_linea_actual (detail page) filters borrado_en IS NULL with no fallback and returns nothing. AG986KG is not special, it is 1 of 131. Timing: 24 vehicles on 2026-03-02, ~103 across 2026-04-20..2026-05-05 - shape of bulk operations, not a per-baja code path. Actor unknown because attribution is zero fleet-wide: 2440 of 2440 soft-deleted historial rows have borrado_por NULL/blank. LATENT: v_vehiculos_linea_actual has no DISTINCT ON, so a vehicle with two active historial rows would fan out and duplicate in the UI; 0 today, so latent. Three baja handlings coexist in prod: 131 deleted-with-nothing-left, 3 open-without-expediente_baja (AE060XC/AE631MI/PQP070), 3 open-WITH-expediente_baja (AI357EF/EG/EH, MOVILBA-44) which is the correct pattern and the newest.
  • wi-cli-venus completed · 2026-08-20
    APPLIED to PROD 2026-08-20, COMMIT, verified as the APP role svc_nextjs so the census reflects what the running app sees. 1736 vivos, 0 without linea, 0 without entidad (were 131 and 131). Export unchanged 1736 = 1599 Alta + 137 Baja. v_vehiculos_detalle 1736 rows = 1736 distinct vehiculos, no fan-out. AG986KG, the row that opened the ticket: now Baja, interno 56, linea 34, entidad JUAN B. JUSTO - previously NULL / 'No asignada'. SCOPE INCLUDED v_vehiculos_entidad_actual: identical no-fallback defect, and fixing only linea would have left the same 131 showing a linea next to 'Entidad: No asignada'. Both now read v_vehiculos_hist_ultimo instead of carrying their own copy of the resolution rule - one rule in one place. CLOSES Eugenia's 2026-08-18 ficha report as a side effect (ficha said 'No asignada' while the Historial tab showed the entidad: two panels, two sources). No table, row or trigger touched - two view definitions and two GRANTs. REHEARSAL FINDING WORTH KEEPING: the first rehearsal passed gates 0/1/2 as svc_nextjs and then FAILED at CREATE OR REPLACE VIEW with 'permission denied for schema public' - prod DDL needs the elazar superuser. A file that 'passed its gates' was still going to fail on the statement that matters; rehearsing as the wrong role proves nothing about the DDL. Confirms reference_prod_ddl_needs_superuser_svc_nextjs_denied.
bug
2026-08-20 by wi-cli-venus
2026-08-20
2026-08-20 07:08