-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
- Loading branch information
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-- Alter "teams" table | ||
ALTER TABLE "public"."teams" DROP COLUMN "is_default"; | ||
|
||
CREATE OR REPLACE FUNCTION public.post_user_signup() | ||
RETURNS TRIGGER | ||
LANGUAGE plpgsql | ||
AS $post_user_signup$ | ||
DECLARE | ||
team_id uuid; | ||
BEGIN | ||
RAISE NOTICE 'Creating default team for user %', NEW.id; | ||
INSERT INTO public.teams(name, tier, email) VALUES (NEW.email, 'base_v1', NEW.email) RETURNING id INTO team_id; | ||
INSERT INTO public.users_teams(user_id, team_id, is_default) VALUES (NEW.id, team_id, true); | ||
RAISE NOTICE 'Created default team for user % and team %', NEW.id, team_id; | ||
|
||
-- Generate a random 20 byte string and encode it as hex, so it's 40 characters | ||
INSERT INTO public.team_api_keys (team_id) | ||
VALUES (team_id); | ||
|
||
INSERT INTO public.access_tokens (user_id) | ||
VALUES (NEW.id); | ||
|
||
PERFORM public.extra_for_post_user_signup(NEW.id, team_id); | ||
|
||
RETURN NEW; | ||
END | ||
$post_user_signup$ SECURITY DEFINER SET search_path = public; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.