15 lines
754 B
SQL
15 lines
754 B
SQL
CREATE TABLE IF NOT EXISTS public.activity_resource_assignments (
|
|
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
activity_id uuid NOT NULL REFERENCES public.activities(id) ON DELETE CASCADE,
|
|
resource_id uuid NOT NULL REFERENCES public.resources(id) ON DELETE CASCADE,
|
|
utilization_minutes numeric NOT NULL DEFAULT 0,
|
|
units numeric NOT NULL DEFAULT 1,
|
|
scenario text NOT NULL DEFAULT 'actual' CHECK (scenario IN ('actual','automated'))
|
|
);
|
|
|
|
ALTER TABLE public.activity_resource_assignments ENABLE ROW LEVEL SECURITY;
|
|
|
|
CREATE POLICY "all_assignments" ON public.activity_resource_assignments
|
|
FOR ALL USING (auth.uid() IS NOT NULL)
|
|
WITH CHECK (auth.uid() IS NOT NULL);
|