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