{
  "id": 23450618,
  "title": "Ownership transfer was a one-row UPDATE. Then we added least-privilege.",
  "url": "https://urgent.news/2026/12/04/ownership-transfer-was-a-one-row-update-then-we-added-least-privilege",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-12-04T14:41:39.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/omer_hochman/ownership-transfer-was-a-one-row-update-then-we-added-least-privilege-1kkh"
  },
  "original_language": null,
  "account": "The ownership transfer of a database in a multi-tenant Postgres setup was initially a simple one-row UPDATE to the registry row, flipping the tenant_id. However, as the application evolved, least-privilege security measures were added, requiring a more complex process to ensure proper authorization. The transfer path updated only one location, the registry row, while other places like the role itself, grants, role membership, and policy literals needed to be updated as well. This discrepancy caused transferred databases to become unqueryable.\n\nThe error was initially difficult to diagnose, as it appeared as a generic \"couldn't reach the database\" message, masking the root cause. It took nine attempts to realize that the failure was not transient, but rather due to deterministic errors caused by the missing role. The solution involved updating every place where authorization state is stored, including the role existence, grants, role membership, and policy literals, in an idempotent manner. This required a comprehensive audit of the codebase to identify and address all transfer paths. Additionally, a catch-all error branch must be implemented to log the specific error codes, providing clearer insights for debugging.",
  "summary": "Originally published at nlqdb.com/blog Multi-tenant Postgres, one schema per tenant database. On day one, every query ran as the shared owner role, so \"transfer this database to the user who just signed in\" was honestly a one-row registry UPDATE — flip tenant_id , done. We wrote that down as a design decision, and it was the right one at the time. Least-privilege arrived; the transfer path didn't…",
  "summary_source": "publisher",
  "key_points": [],
  "editors_take": null,
  "opinion": false,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "outlets_capped": false,
    "also_reported_by": []
  },
  "machine_translated": false,
  "ai_generated": true,
  "disclaimer": "Accounts, briefs, key points, the editor’s take and translations are written by software from other outlets’ reporting and may contain errors. A summary whose summary_source is \"publisher\" is the outlet’s own feed text. Always check the linked original."
}