-- Denormalized postgate upsert: Update posts table directly
-- Postgates control embedding permissions - now stored in posts table
-- Parameters: $1=actor_id, $2=post_rkey, $3=rules[], $4=detached_actor_ids[], $5=detached_rkeys[]
-- Note: We update the post record ($1, $2) with postgate data
-- The postgate's own (actor_id, rkey, cid) are no longer stored separately

UPDATE posts
SET
    postgate_rules = $3::text[]::postgate_rule[],
    postgate_detached_actor_ids = $4::integer[],
    postgate_detached_rkeys = $5::bigint[]
WHERE actor_id = $1
  AND rkey = $2
