Another fix to portal_page__delete
(new-portal/sql/postgresql/api-creates.sql):
Change:
update portal_pages
set sort_key = -1
where sort_key = i;
update portal_pages
set sort_key = i - 1
where sort_key = -1;
to
update portal_pages
set sort_key = -1
where sort_key = i
and portal_id = v_portal_id;
update portal_pages
set sort_key = i - 1
where sort_key = -1
and portal_id = v_portal_id;
Without this fix, deleting an existing page will throw a constraint error.