Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot]
2026-04-26 08:35:10 +00:00
co-authored by renee-png
parent cfbdb74860
commit fc8bb95010
2 changed files with 61 additions and 0 deletions
+30
View File
@@ -2349,6 +2349,36 @@ export type Database = {
},
]
}
ledger_templates: {
Row: {
created_at: string
created_by: string | null
description: string | null
entries: Json
id: string
name: string
updated_at: string
}
Insert: {
created_at?: string
created_by?: string | null
description?: string | null
entries?: Json
id?: string
name: string
updated_at?: string
}
Update: {
created_at?: string
created_by?: string | null
description?: string | null
entries?: Json
id?: string
name?: string
updated_at?: string
}
Relationships: []
}
message_attachments: {
Row: {
created_at: string
@@ -0,0 +1,31 @@
-- Reusable ledger templates: a named bundle of ledger entry definitions
-- that can be applied to any homeowner collection ledger.
CREATE TABLE public.ledger_templates (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
name text NOT NULL,
description text,
entries jsonb NOT NULL DEFAULT '[]'::jsonb,
created_by uuid,
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now()
);
ALTER TABLE public.ledger_templates ENABLE ROW LEVEL SECURITY;
CREATE POLICY lt_select_auth ON public.ledger_templates
FOR SELECT TO authenticated USING (true);
CREATE POLICY lt_insert_auth ON public.ledger_templates
FOR INSERT TO authenticated WITH CHECK (auth.uid() IS NOT NULL);
CREATE POLICY lt_update_owner ON public.ledger_templates
FOR UPDATE TO authenticated
USING (is_admin(auth.uid()) OR created_by = auth.uid());
CREATE POLICY lt_delete_owner ON public.ledger_templates
FOR DELETE TO authenticated
USING (is_admin(auth.uid()) OR created_by = auth.uid());
CREATE TRIGGER trg_ledger_templates_touch
BEFORE UPDATE ON public.ledger_templates
FOR EACH ROW EXECUTE FUNCTION public.tg_set_updated_at();