bharath/webapp/supabase-trips-migration.sql
Vivek 394117dd74 BharathTrucks MVP - 6 sprints complete
- Govt-app styled freight marketplace
- Role-based auth (driver/shipper/broker/admin)
- Load board with bidding system
- Trip tracking with status flow
- In-app messaging
- Admin panel
- Mobile bottom nav + PWA
- Docker + Coolify ready
2026-05-31 06:21:13 +00:00

24 lines
1 KiB
SQL

-- ============================================================
-- BharathTrucks — Trips Migration
-- Run AFTER loads migration
-- ============================================================
CREATE TABLE IF NOT EXISTS trips (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
load_id UUID NOT NULL REFERENCES loads(id),
driver_id UUID NOT NULL REFERENCES app_users(id),
shipper_id UUID NOT NULL REFERENCES app_users(id),
bid_id UUID NOT NULL REFERENCES bids(id),
amount NUMERIC(10,2) NOT NULL,
status TEXT DEFAULT 'confirmed' CHECK (status IN ('confirmed', 'picked_up', 'in_transit', 'delivered', 'cancelled')),
picked_up_at TIMESTAMPTZ,
delivered_at TIMESTAMPTZ,
created_at TIMESTAMPTZ DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS idx_trips_driver ON trips(driver_id);
CREATE INDEX IF NOT EXISTS idx_trips_shipper ON trips(shipper_id);
CREATE INDEX IF NOT EXISTS idx_trips_status ON trips(status);
ALTER TABLE trips ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Allow all on trips" ON trips FOR ALL USING (true) WITH CHECK (true);