This repository has been archived on 2020-04-21. You can view files and clone it, but cannot push or open issues or pull requests.
lemmy/server/migrations/2019-04-03-155205_create_community_view/up.sql
Dessalines 7b1fb030b3 Adding a sidebar, title, and forum categories
- Adding a Sidebar component
- Starting on forum categories. #17
- Adding a Sidebar and title to community. Fixes #16
2019-04-03 16:01:20 -07:00

17 lines
671 B
SQL

create view community_view as
select *,
(select name from user_ u where c.creator_id = u.id) as creator_name,
(select name from category ct where c.category_id = ct.id) as category_name,
(select count(*) from community_follower cf where cf.community_id = c.id) as number_of_subscribers,
(select count(*) from post p where p.community_id = c.id) as number_of_posts
from community c;
create view community_moderator_view as
select *,
(select name from user_ u where cm.user_id = u.id) as user_name
from community_moderator cm;
create view community_follower_view as
select *,
(select name from user_ u where cf.user_id = u.id) as user_name
from community_follower cf;