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
24 lines
1.1 KiB
SQL
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;
|