mirror of
https://github.com/renee-png/acmcc.git
synced 2026-06-21 09:50:01 +00:00
183fe0a93c
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
23 lines
1.0 KiB
SQL
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;
|