Merge branch 'master' into 'feat/filter-by-time'

# Conflicts:
#   src/lib/database.d.ts
#   src/routes/+page.svelte
#   src/routes/space/[id]/+page.svelte
This commit is contained in:
Temesgen, Tadios
2025-06-12 14:54:04 +00:00
16 changed files with 1114 additions and 439 deletions

View File

@@ -0,0 +1,28 @@
CREATE TABLE users (
id uuid PRIMARY KEY REFERENCES auth.users ON DELETE CASCADE,
is_admin boolean NOT NULL DEFAULT false,
created_at timestamp with time zone NOT NULL DEFAULT now(),
updated_at timestamp with time zone NOT NULL DEFAULT now()
);
CREATE TRIGGER users_handle_updated_at
AFTER UPDATE ON users
FOR EACH ROW EXECUTE FUNCTION handle_updated_at();
-- Auto-create users when auth.users are created
CREATE FUNCTION handle_new_user()
RETURNS trigger
LANGUAGE plpgsql
SECURITY DEFINER
SET search_path = ''
AS $$
BEGIN
INSERT INTO public.users (id, contact_email)
VALUES (NEW.id, NEW.email);
RETURN NEW;
END;
$$;
CREATE TRIGGER users_handle_new_user
AFTER INSERT ON auth.users
FOR EACH ROW EXECUTE FUNCTION handle_new_user();