Files
acmcc/supabase/migrations/20260316161421_ec327786-df4f-47d1-b31e-4dec1df66e39.sql
T
2026-06-01 20:19:26 -04:00

23 lines
1.0 KiB
SQL

-- Create violation_types table for configurable violation categories per association
CREATE TABLE IF NOT EXISTS public.violation_types (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
association_id uuid REFERENCES public.associations(id) ON DELETE CASCADE NOT NULL,
category text NOT NULL,
description text,
created_at timestamptz DEFAULT now(),
updated_at timestamptz DEFAULT now()
);
ALTER TABLE public.violation_types ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Authenticated users can manage violation_types"
ON public.violation_types FOR ALL TO authenticated USING (true) WITH CHECK (true);
-- Add missing columns to violations for inspection workflow
ALTER TABLE public.violations ADD COLUMN IF NOT EXISTS address text;
ALTER TABLE public.violations ADD COLUMN IF NOT EXISTS violation_type text;
ALTER TABLE public.violations ADD COLUMN IF NOT EXISTS violation_date date DEFAULT CURRENT_DATE;
ALTER TABLE public.violations ADD COLUMN IF NOT EXISTS notes text;
ALTER TABLE public.violations ADD COLUMN IF NOT EXISTS property_id uuid;