summaryrefslogtreecommitdiffstats
path: root/server/migrations
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2019-08-28 21:28:06 -0700
committerDessalines <tyhou13@gmx.com>2019-08-28 21:28:06 -0700
commitb50ae1dafc7c34029809f6af252ca4886b0f8414 (patch)
tree12756ddbe6a8f01f2cfde2f3da345ade71863314 /server/migrations
parentde8c2198afb61ae45d2210125c67a49422b9a2e8 (diff)
Showing community count on main sidebar
- Fixes #232
Diffstat (limited to 'server/migrations')
-rw-r--r--server/migrations/2019-08-29-040006_add_community_count/down.sql9
-rw-r--r--server/migrations/2019-08-29-040006_add_community_count/up.sql10
2 files changed, 19 insertions, 0 deletions
diff --git a/server/migrations/2019-08-29-040006_add_community_count/down.sql b/server/migrations/2019-08-29-040006_add_community_count/down.sql
new file mode 100644
index 00000000..6302f267
--- /dev/null
+++ b/server/migrations/2019-08-29-040006_add_community_count/down.sql
@@ -0,0 +1,9 @@
+drop view site_view;
+
+create view site_view as
+select *,
+(select name from user_ u where s.creator_id = u.id) as creator_name,
+(select count(*) from user_) as number_of_users,
+(select count(*) from post) as number_of_posts,
+(select count(*) from comment) as number_of_comments
+from site s;
diff --git a/server/migrations/2019-08-29-040006_add_community_count/up.sql b/server/migrations/2019-08-29-040006_add_community_count/up.sql
new file mode 100644
index 00000000..0ec1c9c3
--- /dev/null
+++ b/server/migrations/2019-08-29-040006_add_community_count/up.sql
@@ -0,0 +1,10 @@
+drop view site_view;
+
+create view site_view as
+select *,
+(select name from user_ u where s.creator_id = u.id) as creator_name,
+(select count(*) from user_) as number_of_users,
+(select count(*) from post) as number_of_posts,
+(select count(*) from comment) as number_of_comments,
+(select count(*) from community) as number_of_communities
+from site s;