Files
ims/supabase/migrations/20260713000004_trucks.sql
T
adminandClaude Sonnet 4.6 ebeab27e5e feat(db): trucks table, transport enum value, incidents.truck_id FK
- ALTER TYPE incident_type ADD VALUE 'transport' (isolated migration)
- trucks table with truck_no (unique), carrier, active, RLS mirroring sites
- incidents.truck_id UUID FK + index

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CPf5Rc8QPx6V8KLEEgfKEQ
2026-07-13 10:49:06 +08:00

15 lines
564 B
SQL

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');