2 DROP TRIGGER IF EXISTS post_aggregates_featured_local ON post;
3 DROP TRIGGER IF EXISTS post_aggregates_featured_community ON post;
4 drop function post_aggregates_featured_community;
5 drop function post_aggregates_featured_local;
8 alter table post ADD stickied boolean NOT NULL DEFAULT false;
10 set stickied = featured_community;
11 alter table post DROP COLUMN featured_community;
12 alter table post DROP COLUMN featured_local;
14 alter table post_aggregates ADD stickied boolean NOT NULL DEFAULT false;
15 Update post_aggregates
16 set stickied = featured_community;
17 alter table post_aggregates DROP COLUMN featured_community;
18 alter table post_aggregates DROP COLUMN featured_local;
20 alter table mod_feature_post
21 rename column featured TO stickied;
23 alter table mod_feature_post
24 DROP COLUMN is_featured_community;
26 alter table mod_feature_post
27 alter column stickied DROP NOT NULL;
29 alter table mod_feature_post
30 Rename To mod_sticky_post;
32 create function post_aggregates_stickied()
33 returns trigger language plpgsql
36 update post_aggregates pa
37 set stickied = NEW.stickied
38 where pa.post_id = NEW.id;
43 create trigger post_aggregates_stickied
46 when (OLD.stickied is distinct from NEW.stickied)
47 execute procedure post_aggregates_stickied();