-- 20260831: Org-scope Helping Hand / ROSCA Matching Fund FK scoping
ALTER TABLE helping_hand_applications
ADD COLUMN IF NOT EXISTS organization_id INTEGER REFERENCES organizations(id);

CREATE INDEX IF NOT EXISTS hh_apps_org_created_idx
  ON helping_hand_applications(organization_id, created_at);

ALTER TABLE helping_hand_repayments
ADD COLUMN IF NOT EXISTS organization_id INTEGER REFERENCES organizations(id);

CREATE INDEX IF NOT EXISTS hh_repayments_org_due_idx
  ON helping_hand_repayments(organization_id, status, due_date);
