2 DROP TRIGGER IF EXISTS post_aggregates_stickied ON post;
4 post_aggregates_stickied;
7 alter table post ADD featured_community boolean NOT NULL DEFAULT false;
8 alter table post ADD featured_local boolean NOT NULL DEFAULT false;
10 set featured_community = stickied;
11 alter table post DROP COLUMN stickied;
13 alter table post_aggregates ADD featured_community boolean NOT NULL DEFAULT false;
14 alter table post_aggregates ADD featured_local boolean NOT NULL DEFAULT false;
15 update post_aggregates
16 set featured_community = stickied;
17 alter table post_aggregates DROP COLUMN stickied;
19 alter table mod_sticky_post
20 rename column stickied TO featured;
22 alter table mod_sticky_post
23 alter column featured SET NOT NULL;
25 alter table mod_sticky_post
26 ADD is_featured_community boolean NOT NULL DEFAULT true;
28 alter table mod_sticky_post
29 Rename To mod_feature_post;
31 create function post_aggregates_featured_community()
32 returns trigger language plpgsql
35 update post_aggregates pa
36 set featured_community = NEW.featured_community
37 where pa.post_id = NEW.id;
41 create function post_aggregates_featured_local()
42 returns trigger language plpgsql
45 update post_aggregates pa
46 set featured_local = NEW.featured_local
47 where pa.post_id = NEW.id;
51 CREATE TRIGGER post_aggregates_featured_community
55 WHEN (old.featured_community IS DISTINCT FROM new.featured_community)
56 EXECUTE FUNCTION public.post_aggregates_featured_community();
58 CREATE TRIGGER post_aggregates_featured_local
62 WHEN (old.featured_local IS DISTINCT FROM new.featured_local)
63 EXECUTE FUNCTION public.post_aggregates_featured_local();