docs: BUG-06 closed — migration shifted 3593 rows +4h EDT, recomputed 43 trips, times now correct
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
-- Fix existing tracking_points and trips: Pi stores naive local time (EDT/EST)
|
||||
-- but Postgres TIMESTAMPTZ interprets naive strings as UTC. Shift by the Pi's
|
||||
-- UTC offset (EDT = UTC-4, EST = UTC-5). In August 2026 the Pi is in EDT.
|
||||
-- Run this ONE TIME after deploying the BUG-06 _to_tz_aware() upload fix.
|
||||
-- New uploads already include a timezone offset and are NOT affected.
|
||||
|
||||
-- Step 1: Shift all existing tracking_points by +4 hours (EDT → UTC)
|
||||
UPDATE tracking_points
|
||||
SET recorded_at = recorded_at + INTERVAL '4 hours'
|
||||
WHERE recorded_at IS NOT NULL;
|
||||
|
||||
-- Step 2: Shift all computed trips (derived from tracking_points)
|
||||
UPDATE trips
|
||||
SET start_time = start_time + INTERVAL '4 hours',
|
||||
end_time = end_time + INTERVAL '4 hours'
|
||||
WHERE start_time IS NOT NULL;
|
||||
|
||||
-- Step 3: Clear deleted-trip markers so a full recompute regenerates correct
|
||||
-- trip boundaries from the now-correct tracking_points timestamps.
|
||||
DELETE FROM deleted_trip_markers;
|
||||
|
||||
-- Step 4: Drop existing trips so the next Pi upload (or manual recompute)
|
||||
-- rebuilds them from the corrected tracking_points.
|
||||
DELETE FROM trips;
|
||||
Reference in New Issue
Block a user