PostText/migrations/6/up.sql

13 lines
290 B
MySQL
Raw Normal View History

2022-10-08 04:42:31 +00:00
ALTER TABLE threads
ADD COLUMN bump_count INTEGER
NOT NULL
DEFAULT 0;
UPDATE threads t
SET bump_count = r.remark_count
FROM (SELECT COUNT(*) AS remark_count,
thread_id
FROM remarks
GROUP BY thread_id) AS r
WHERE t.thread_id = r.thread_id;