···11alter table posts
22 drop column mentions,
33- drop column violates_threadgate;33+ drop column violates_threadgate;
44+55+drop trigger t_author_feed_ins_post on posts;
66+drop trigger t_author_feed_del_post on posts;
77+drop trigger t_author_feed_ins_repost on reposts;
88+drop trigger t_author_feed_del_repost on reposts;
99+1010+drop function f_author_feed_ins_post;
1111+drop function f_author_feed_del_post;
1212+drop function f_author_feed_ins_repost;
1313+drop function f_author_feed_del_repost;
1414+1515+drop table author_feeds;
+77-1
migrations/2025-09-27-171241_post-tweaks/up.sql
···11alter table posts
22 add column mentions text[],
33- add column violates_threadgate bool not null default false;33+ add column violates_threadgate bool not null default false;
44+55+create table author_feeds
66+(
77+ uri text primary key,
88+ cid text not null,
99+ post text not null,
1010+ did text not null,
1111+ typ text not null,
1212+ sort_at timestamptz not null
1313+);
1414+1515+-- author_feeds post triggers
1616+create function f_author_feed_ins_post() returns trigger
1717+ language plpgsql as
1818+$$
1919+begin
2020+ insert into author_feeds (uri, cid, post, did, typ, sort_at)
2121+ VALUES (NEW.at_uri, NEW.cid, NEW.at_uri, NEW.did, 'post', NEW.created_at)
2222+ on conflict do nothing;
2323+ return NEW;
2424+end;
2525+$$;
2626+2727+create trigger t_author_feed_ins_post
2828+ before insert
2929+ on posts
3030+ for each row
3131+execute procedure f_author_feed_ins_post();
3232+3333+create function f_author_feed_del_post() returns trigger
3434+ language plpgsql as
3535+$$
3636+begin
3737+ delete from author_feeds where did = OLD.did and item = OLD.at_uri and typ = 'post';
3838+ return OLD;
3939+end;
4040+$$;
4141+4242+create trigger t_author_feed_del_post
4343+ before delete
4444+ on posts
4545+ for each row
4646+execute procedure f_author_feed_del_post();
4747+4848+-- author_feeds repost triggers
4949+create function f_author_feed_ins_repost() returns trigger
5050+ language plpgsql as
5151+$$
5252+begin
5353+ insert into author_feeds (uri, cid, post, did, typ, sort_at)
5454+ VALUES ('at://' || NEW.did || 'app.bsky.feed.repost' || NEW.rkey, NEW.post_cid, NEW.post, NEW.did, 'repost', NEW.created_at)
5555+ on conflict do nothing;
5656+ return NEW;
5757+end;
5858+$$;
5959+6060+create trigger t_author_feed_ins_repost
6161+ before insert
6262+ on reposts
6363+ for each row
6464+execute procedure f_author_feed_ins_repost();
6565+6666+create function f_author_feed_del_repost() returns trigger
6767+ language plpgsql as
6868+$$
6969+begin
7070+ delete from author_feeds where did = OLD.did and item = OLD.post and typ = 'repost';
7171+ return OLD;
7272+end;
7373+$$;
7474+7575+create trigger t_author_feed_del_repost
7676+ before delete
7777+ on reposts
7878+ for each row
7979+execute procedure f_author_feed_del_repost();