diff --git a/supabase/migrations/20260713000003_transport_incident_type.sql b/supabase/migrations/20260713000003_transport_incident_type.sql new file mode 100644 index 0000000..ed82a9c --- /dev/null +++ b/supabase/migrations/20260713000003_transport_incident_type.sql @@ -0,0 +1,3 @@ +-- Add 'transport' to the incident_type enum. Isolated so the new value is +-- committed before any later migration references it. +ALTER TYPE incident_type ADD VALUE IF NOT EXISTS 'transport'; diff --git a/supabase/migrations/20260713000004_trucks.sql b/supabase/migrations/20260713000004_trucks.sql new file mode 100644 index 0000000..68c750f --- /dev/null +++ b/supabase/migrations/20260713000004_trucks.sql @@ -0,0 +1,14 @@ +CREATE TABLE trucks ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + truck_no TEXT NOT NULL UNIQUE, + carrier TEXT, + active BOOLEAN NOT NULL DEFAULT true, + created_at TIMESTAMPTZ NOT NULL DEFAULT now() +); + +ALTER TABLE incidents ADD COLUMN truck_id UUID REFERENCES trucks(id); +CREATE INDEX incidents_truck_id_idx ON incidents(truck_id); + +ALTER TABLE trucks ENABLE ROW LEVEL SECURITY; +CREATE POLICY "trucks_read" ON trucks FOR SELECT USING (true); +CREATE POLICY "trucks_admin_all" ON trucks FOR ALL USING (auth_user_role() = 'admin');