generated from theodorusclarence/ts-nextjs-tailwind-starter
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: user can join upto 3 teams only. backend
- Loading branch information
1 parent
d91fb4e
commit 9021263
Showing
7 changed files
with
122 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
supabase/migrations/20240622200901_function-to-avoid-rls-update-in-profiles.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
alter table "public"."teams-members" add constraint "public_teams-members_team_id_fkey" FOREIGN KEY (team_id) REFERENCES teams(team_id) ON UPDATE CASCADE ON DELETE CASCADE not valid; | ||
|
||
alter table "public"."teams-members" validate constraint "public_teams-members_team_id_fkey"; | ||
|
||
set check_function_bodies = off; | ||
|
||
CREATE OR REPLACE FUNCTION public.update_teams_joined(requester_id uuid, user_id uuid, updated_teams_joined smallint) | ||
RETURNS void | ||
LANGUAGE plpgsql | ||
SECURITY DEFINER | ||
AS $function$ | ||
BEGIN | ||
UPDATE profiles | ||
SET teams_joined = updated_teams_joined | ||
WHERE id = user_id; | ||
END; | ||
$function$ | ||
; | ||
|
||
|