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:
28
supabase/migrations/20250612104310_users-admin.sql
Normal file
28
supabase/migrations/20250612104310_users-admin.sql
Normal 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();
|
||||
28
supabase/schemas/0001_users.sql
Normal file
28
supabase/schemas/0001_users.sql
Normal 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();
|
||||
Reference in New Issue
Block a user