freightdesk/supabase/migrations/007_location_tracking.sql
FreightDesk 59d93d5281
Some checks are pending
FreightDesk CI/CD / Lint & Test (push) Waiting to run
FreightDesk CI/CD / Build Docker Image (push) Blocked by required conditions
FreightDesk CI/CD / Deploy to Coolify (push) Blocked by required conditions
[OWL] Driver location tracking + bulk WhatsApp parser + deployment docs
Location Tracking:
- POST /api/location/update — driver GPS update
- GET /api/location/:load_id — get driver location for load
- Migration 007: vehicle_locations table with spatial indexes

Bulk WhatsApp Parser:
- UI for pasting multiple messages at once
- Batch parse via /api/parse-whatsapp
- Review parsed results with confidence scores
- Select and save all valid loads to database
- One-click import from WhatsApp to loads

Deployment:
- DEPLOYMENT.md: full deployment guide
- Environment configuration
- Docker + Docker Compose setup
- Coolify deployment steps
- Post-deployment checklist
- Troubleshooting guide
- Architecture diagram
2026-06-08 01:59:05 +00:00

24 lines
1.1 KiB
SQL

-- ============================================================
-- FreightDesk — Migration 007: Driver Location Tracking
-- GPS location history for real-time tracking
-- ============================================================
CREATE TABLE IF NOT EXISTS vehicle_locations (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
vehicle_id UUID NOT NULL REFERENCES vehicles(id) ON DELETE CASCADE,
lat DECIMAL(10,8) NOT NULL,
lng DECIMAL(11,8) NOT NULL,
accuracy DECIMAL(8,2),
heading DECIMAL(6,2),
speed DECIMAL(6,2),
recorded_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS idx_vehicle_locations_vehicle ON vehicle_locations(vehicle_id);
CREATE INDEX IF NOT EXISTS idx_vehicle_locations_time ON vehicle_locations(recorded_at);
CREATE INDEX IF NOT EXISTS idx_vehicle_locations_vehicle_time ON vehicle_locations(vehicle_id, recorded_at DESC);
-- Enable PostGIS-like functionality with btree_gist for spatial queries
-- (In production, use PostGIS extension)
CREATE INDEX IF NOT EXISTS idx_vehicles_location ON vehicles(current_lat, current_lng)
WHERE current_lat IS NOT NULL AND current_lng IS NOT NULL;