MEga push vol idk, chat function updates, docker fixes

This commit is contained in:
AlacrisDevs
2026-02-14 13:09:45 +02:00
parent c2d3caaa5a
commit 7ab206fe96
35 changed files with 1226 additions and 1344 deletions

View File

@@ -0,0 +1,19 @@
-- Fix handle_new_org trigger: use auth.uid() instead of NEW.created_by
-- The organizations table has no created_by column, so the trigger was inserting NULL
-- as user_id into org_members, causing org creation to fail.
CREATE OR REPLACE FUNCTION public.handle_new_org()
RETURNS trigger
LANGUAGE plpgsql
SECURITY DEFINER
SET search_path = ''
AS $$
BEGIN
-- Add creator as owner (use auth.uid() since organizations has no created_by column)
INSERT INTO public.org_members (org_id, user_id, role, joined_at)
VALUES (NEW.id, auth.uid(), 'owner', now());
-- Create default roles
PERFORM public.create_default_org_roles(NEW.id);
RETURN NEW;
END;
$$;