diff options
author | ubq323 <ubq323> | 2021-06-23 17:11:14 +0000 |
---|---|---|
committer | ubq323 <ubq323> | 2021-06-23 17:11:14 +0000 |
commit | 0efffb90e4540d7883cdddfeeb887e271c8f065f (patch) | |
tree | b57f8194946fc39588a8e766f93e260017edd63c /apioforum/db.py | |
parent | ddc62e940d7c521801b9d00167acc0b0392e951a (diff) |
many database things, not really related to subforums but it's probably better to do all these things at the same time
Diffstat (limited to 'apioforum/db.py')
-rw-r--r-- | apioforum/db.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/apioforum/db.py b/apioforum/db.py index 84f268d..7dd635e 100644 --- a/apioforum/db.py +++ b/apioforum/db.py @@ -110,6 +110,13 @@ ALTER TABLE threads_new RENAME TO threads; COMMIT; PRAGMA foreign_keys = on; """, +""" +CREATE VIEW most_recent_posts AS + SELECT max(id), * FROM posts GROUP BY thread; + +CREATE VIEW number_of_posts AS + SELECT thread, count(*) AS num_replies FROM posts GROUP BY thread; +""", ] |