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
This commit is contained in:
@@ -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');
|
||||
Reference in New Issue
Block a user