Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot]
2026-04-18 16:40:41 +00:00
co-authored by renee-png
parent 7c761ac790
commit 1dd6dbefff
2 changed files with 54 additions and 0 deletions
@@ -0,0 +1,27 @@
CREATE TABLE public.form_settings (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
form_key text NOT NULL UNIQUE,
config jsonb NOT NULL DEFAULT '{}'::jsonb,
updated_by uuid,
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now()
);
ALTER TABLE public.form_settings ENABLE ROW LEVEL SECURITY;
CREATE POLICY form_settings_select_auth ON public.form_settings
FOR SELECT TO authenticated USING (true);
CREATE POLICY form_settings_insert_admin ON public.form_settings
FOR INSERT TO authenticated WITH CHECK (public.is_admin(auth.uid()));
CREATE POLICY form_settings_update_admin ON public.form_settings
FOR UPDATE TO authenticated USING (public.is_admin(auth.uid()));
CREATE POLICY form_settings_delete_admin ON public.form_settings
FOR DELETE TO authenticated USING (public.is_admin(auth.uid()));
CREATE TRIGGER tg_form_settings_updated_at
BEFORE UPDATE ON public.form_settings
FOR EACH ROW EXECUTE FUNCTION public.tg_set_updated_at();