Changes
Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
co-authored by
renee-png
parent
097c3b14e0
commit
b14a968191
@@ -524,6 +524,38 @@ export type Database = {
|
||||
},
|
||||
]
|
||||
}
|
||||
document_folders: {
|
||||
Row: {
|
||||
case_id: string
|
||||
created_at: string
|
||||
created_by: string | null
|
||||
id: string
|
||||
path: string
|
||||
}
|
||||
Insert: {
|
||||
case_id: string
|
||||
created_at?: string
|
||||
created_by?: string | null
|
||||
id?: string
|
||||
path: string
|
||||
}
|
||||
Update: {
|
||||
case_id?: string
|
||||
created_at?: string
|
||||
created_by?: string | null
|
||||
id?: string
|
||||
path?: string
|
||||
}
|
||||
Relationships: [
|
||||
{
|
||||
foreignKeyName: "document_folders_case_id_fkey"
|
||||
columns: ["case_id"]
|
||||
isOneToOne: false
|
||||
referencedRelation: "cases"
|
||||
referencedColumns: ["id"]
|
||||
},
|
||||
]
|
||||
}
|
||||
document_templates: {
|
||||
Row: {
|
||||
body: string
|
||||
@@ -571,6 +603,7 @@ export type Database = {
|
||||
case_id: string
|
||||
created_at: string
|
||||
description: string | null
|
||||
folder: string
|
||||
id: string
|
||||
mime_type: string | null
|
||||
name: string
|
||||
@@ -582,6 +615,7 @@ export type Database = {
|
||||
case_id: string
|
||||
created_at?: string
|
||||
description?: string | null
|
||||
folder?: string
|
||||
id?: string
|
||||
mime_type?: string | null
|
||||
name: string
|
||||
@@ -593,6 +627,7 @@ export type Database = {
|
||||
case_id?: string
|
||||
created_at?: string
|
||||
description?: string | null
|
||||
folder?: string
|
||||
id?: string
|
||||
mime_type?: string | null
|
||||
name?: string
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
ALTER TABLE public.documents ADD COLUMN IF NOT EXISTS folder text NOT NULL DEFAULT '';
|
||||
CREATE INDEX IF NOT EXISTS documents_case_folder_idx ON public.documents (case_id, folder);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.document_folders (
|
||||
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
case_id uuid NOT NULL REFERENCES public.cases(id) ON DELETE CASCADE,
|
||||
path text NOT NULL,
|
||||
created_by uuid,
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
UNIQUE (case_id, path)
|
||||
);
|
||||
|
||||
ALTER TABLE public.document_folders ENABLE ROW LEVEL SECURITY;
|
||||
|
||||
CREATE POLICY "df_select_case" ON public.document_folders FOR SELECT TO authenticated
|
||||
USING (public.can_access_case(case_id, auth.uid()));
|
||||
CREATE POLICY "df_insert_case" ON public.document_folders FOR INSERT TO authenticated
|
||||
WITH CHECK (public.can_access_case(case_id, auth.uid()));
|
||||
CREATE POLICY "df_delete_case" ON public.document_folders FOR DELETE TO authenticated
|
||||
USING (public.can_access_case(case_id, auth.uid()));
|
||||
Reference in New Issue
Block a user