-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## [1.3.2] - 2024-11-13 #### [@rickypid](https://github.com/rickypid) Improve documentations ### Fixed * Fixed schema `chats` permission after view creation
- Loading branch information
Showing
11 changed files
with
66 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
id: supabase-views | ||
title: Database Views | ||
--- | ||
|
||
## Rooms view | ||
|
||
This is a view of `rooms` table, this view allows you to obtain the name of the sender of the message dynamically in direct rooms, based on the logged-in user the name of the correspondent is displayed. | ||
|
||
```sql | ||
DROP VIEW IF EXISTS chats.rooms_l; | ||
create view chats.rooms_l | ||
WITH (security_invoker='on') as | ||
select | ||
r.id, | ||
r."imageUrl", | ||
r.metadata, | ||
case | ||
when r.type = 'direct' and auth.uid() is not null then | ||
(select coalesce(u."firstName", '') || ' ' || coalesce(u."lastName", '') | ||
from chats.users u | ||
where u.id = any(r."userIds") and u.id <> auth.uid() | ||
limit 1) | ||
else | ||
r.name | ||
end as name, | ||
r.type, | ||
r."userIds", | ||
r."lastMessages", | ||
r."userRoles", | ||
r."createdAt", | ||
r."updatedAt" | ||
from chats.rooms r; | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
GRANT USAGE ON SCHEMA chats TO anon, authenticated, service_role; | ||
GRANT ALL ON ALL TABLES IN SCHEMA chats TO anon, authenticated, service_role; | ||
GRANT ALL ON ALL ROUTINES IN SCHEMA chats TO anon, authenticated, service_role; | ||
GRANT ALL ON ALL SEQUENCES IN SCHEMA chats TO anon, authenticated, service_role; | ||
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA chats GRANT ALL ON TABLES TO anon, authenticated, service_role; | ||
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA chats GRANT ALL ON ROUTINES TO anon, authenticated, service_role; | ||
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA chats GRANT ALL ON SEQUENCES TO anon, authenticated, service_role; |
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