@@ -13,13 +13,29 @@ CREATE TYPE "public"."quote_approval_policy" AS ENUM(
1313ALTER TABLE " posts" ADD COLUMN " quote_target_iri" text ;-- > statement-breakpoint
1414ALTER TABLE " posts" ADD COLUMN " quote_state" " quote_state" ;-- > statement-breakpoint
1515ALTER TABLE " posts" ADD COLUMN " quote_authorization_iri" text ;-- > statement-breakpoint
16- ALTER TABLE " posts" ADD COLUMN " quote_approval_policy" " quote_approval_policy" DEFAULT ' public' NOT NULL ;-- > statement-breakpoint
16+ -- Add this column as nullable and without an immediate default. Existing
17+ -- remote posts did not have quote policy data before this migration, and
18+ -- defaulting every row to 'public' would make legacy remote posts
19+ -- indistinguishable from cached FEP-044f public-policy posts. The following
20+ -- backfill intentionally touches only local posts, where Hollo owns the quote
21+ -- policy and can derive it from existing visibility.
22+ ALTER TABLE " posts" ADD COLUMN " quote_approval_policy" " quote_approval_policy" ;-- > statement-breakpoint
1723UPDATE " posts" AS " post"
1824SET
1925 " quote_target_iri" = " target" ." iri" ,
2026 " quote_state" = ' accepted'
2127FROM " posts" AS " target"
2228WHERE " post" ." quote_target_id" = " target" ." id" ;-- > statement-breakpoint
2329UPDATE " posts"
24- SET " quote_approval_policy" = ' nobody'
25- WHERE " visibility" IN (' private' , ' direct' );
30+ SET " quote_approval_policy" = CASE
31+ WHEN " posts" ." visibility" IN (' private' , ' direct' )
32+ THEN ' nobody' ::" quote_approval_policy"
33+ ELSE ' public' ::" quote_approval_policy"
34+ END
35+ FROM " account_owners"
36+ WHERE " posts" ." actor_id" = " account_owners" ." id" ;-- > statement-breakpoint
37+ -- Set the default only after the local backfill. New local posts keep the
38+ -- public default, while persisted remote posts can still explicitly store NULL
39+ -- when no FEP-044f interaction policy was observed.
40+ ALTER TABLE " posts"
41+ ALTER COLUMN " quote_approval_policy" SET DEFAULT ' public' ;
0 commit comments