]> Untitled Git - lemmy.git/blob - migrations/2023-06-07-105918_add_hot_rank_columns/down.sql
71529bdf0358e843e0de18ced9a7368f4905f01e
[lemmy.git] / migrations / 2023-06-07-105918_add_hot_rank_columns / down.sql
1
2 -- Remove the new columns
3
4 alter table post_aggregates drop column hot_rank;
5 alter table post_aggregates drop column hot_rank_active;
6
7 alter table comment_aggregates drop column hot_rank;
8
9 alter table community_aggregates drop column hot_rank;
10
11 -- Drop some new indexes
12 drop index idx_post_aggregates_score;
13 drop index idx_post_aggregates_published;
14 drop index idx_post_aggregates_newest_comment_time;
15 drop index idx_post_aggregates_newest_comment_time_necro;
16 drop index idx_post_aggregates_featured_community;
17 drop index idx_post_aggregates_featured_local;
18
19 -- Recreate the old indexes
20 CREATE INDEX idx_post_aggregates_featured_local_newest_comment_time ON public.post_aggregates USING btree (featured_local DESC, newest_comment_time DESC);
21 CREATE INDEX idx_post_aggregates_featured_community_newest_comment_time ON public.post_aggregates USING btree (featured_community DESC, newest_comment_time DESC);
22 CREATE INDEX idx_post_aggregates_featured_local_comments ON public.post_aggregates USING btree (featured_local DESC, comments DESC);
23 CREATE INDEX idx_post_aggregates_featured_community_comments ON public.post_aggregates USING btree (featured_community DESC, comments DESC);
24 CREATE INDEX idx_post_aggregates_featured_local_hot ON public.post_aggregates USING btree (featured_local DESC, hot_rank((score)::numeric, published) DESC, published DESC);
25 CREATE INDEX idx_post_aggregates_featured_community_hot ON public.post_aggregates USING btree (featured_community DESC, hot_rank((score)::numeric, published) DESC, published DESC);
26 CREATE INDEX idx_post_aggregates_featured_local_score ON public.post_aggregates USING btree (featured_local DESC, score DESC);
27 CREATE INDEX idx_post_aggregates_featured_community_score ON public.post_aggregates USING btree (featured_community DESC, score DESC);
28 CREATE INDEX idx_post_aggregates_featured_local_published ON public.post_aggregates USING btree (featured_local DESC, published DESC);
29 CREATE INDEX idx_post_aggregates_featured_community_published ON public.post_aggregates USING btree (featured_community DESC, published DESC);
30 CREATE INDEX idx_post_aggregates_featured_local_active ON public.post_aggregates USING btree (featured_local DESC, hot_rank((score)::numeric, newest_comment_time_necro) DESC, newest_comment_time_necro DESC);
31 CREATE INDEX idx_post_aggregates_featured_community_active ON public.post_aggregates USING btree (featured_community DESC, hot_rank((score)::numeric, newest_comment_time_necro) DESC, newest_comment_time_necro DESC);
32
33 CREATE INDEX idx_comment_aggregates_hot ON public.comment_aggregates USING btree (hot_rank((score)::numeric, published) DESC, published DESC);
34
35 CREATE INDEX idx_community_aggregates_hot ON public.community_aggregates USING btree (hot_rank((subscribers)::numeric, published) DESC, published DESC);