Files
yaris-obd/server/sql/migrate_phase26_deleted_trips.sql

11 lines
547 B
SQL

-- Migration: deleted trip markers to prevent recompute from re-inserting
-- manually deleted trips. Each row records a trip the user explicitly
-- removed. compute_trips_for_device() skips time ranges matching any marker.
-- The "Recompute trips" button clears all markers before rebuilding.
CREATE TABLE IF NOT EXISTS deleted_trip_markers (
device_id INTEGER NOT NULL REFERENCES devices(id) ON DELETE CASCADE,
start_time TIMESTAMPTZ NOT NULL,
deleted_at TIMESTAMPTZ NOT NULL DEFAULT now(),
PRIMARY KEY (device_id, start_time)
);