summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2020-08-25 18:31:32 +0200
committerYorhel <git@yorhel.nl>2020-08-25 18:31:32 +0200
commitb92c5d69b61a333b934e2c6925df119035365a5e (patch)
tree441b56d9fd048fc929c2df6d93a0c54ff5c56f19
parent551c31675cf13bbb68b0fcff04ae8ec90c1c00ed (diff)
SQL/reviews: Two rather stupid fixups on reviews_posts
-rw-r--r--sql/tableattrs.sql2
-rw-r--r--sql/triggers.sql2
-rw-r--r--util/updates/2020-08-25-reviews-fixups.sql5
3 files changed, 7 insertions, 2 deletions
diff --git a/sql/tableattrs.sql b/sql/tableattrs.sql
index 34ad8e40..f00db33d 100644
--- a/sql/tableattrs.sql
+++ b/sql/tableattrs.sql
@@ -126,7 +126,7 @@ CREATE INDEX reports_new ON reports (date) WHERE status = 'new
CREATE INDEX reports_lastmod ON reports (lastmod);
CREATE UNIQUE INDEX reviews_vid_uid ON reviews (vid,uid);
CREATE INDEX reviews_uid ON reviews (uid);
-CREATE UNIQUE INDEX reviews_posts_uid ON reviews_posts (uid);
+CREATE INDEX reviews_posts_uid ON reviews_posts (uid);
CREATE UNIQUE INDEX reviews_votes_id_uid ON reviews_votes (id,uid);
CREATE INDEX staff_alias_id ON staff_alias (id);
CREATE UNIQUE INDEX tags_vn_pkey ON tags_vn (tag,vid,uid);
diff --git a/sql/triggers.sql b/sql/triggers.sql
index eeb0c411..bfda6354 100644
--- a/sql/triggers.sql
+++ b/sql/triggers.sql
@@ -299,7 +299,7 @@ BEGIN
UPDATE reviews
SET c_count = COALESCE((SELECT COUNT(*) FROM reviews_posts WHERE NOT hidden AND id = reviews.id), 0)
, c_lastnum = (SELECT MAX(num) FROM reviews_posts WHERE NOT hidden AND id = reviews.id)
- WHERE id IN(OLD.tid,NEW.tid);
+ WHERE id IN(OLD.id,NEW.id);
RETURN NULL;
END
$$ LANGUAGE plpgsql;
diff --git a/util/updates/2020-08-25-reviews-fixups.sql b/util/updates/2020-08-25-reviews-fixups.sql
new file mode 100644
index 00000000..86f77b2a
--- /dev/null
+++ b/util/updates/2020-08-25-reviews-fixups.sql
@@ -0,0 +1,5 @@
+DROP INDEX reviews_posts_uid;
+CREATE INDEX reviews_posts_uid ON reviews_posts (uid);
+
+\i sql/func.sql
+\i sql/triggers.sql