# Rolebook vs SpiceDB: authorize and update in one transaction (https://rolebook.dev/compare/spicedb)

Rolebook fits when your application updates a row in PostgreSQL and the permission check should commit or roll back with that update.

SpiceDB's schema documentation shows permissions computed from relations, including read access to a document through its parent folder. [SpiceDB schema language](https://authzed.com/docs/spicedb/concepts/schema)

## The check and the update share one transaction

`createPostgresProtectedWriteAdapter()` runs one resource-wide action check and your SQL callback in a single `SERIALIZABLE` PostgreSQL transaction, and records a receipt and an outbox event with your change. It needs the PostgreSQL sharing adapter, versioned sharing and a local identity projection in the same database. Your SQL remains trusted application code.

## Renaming a document

`user_123` renames `document_1` in `workspace_1`. If the initial action check refuses, your callback never runs. If it allows, your `UPDATE` must advance the row's version and keep its owner, ancestry and sharing state. The rename, its receipt and its outbox event commit atomically only if the final authority checks succeed.

While that receipt is retained, an exact retry with the same idempotency key returns it without running the callback again.

## In the Rolebook docs

- [Protected application updates](https://rolebook.dev/docs/sharing-postgres/protected-updates)
- [PostgreSQL fences and transactions](https://rolebook.dev/docs/sharing-postgres/fences)
- [Policy versions and custom roles](https://rolebook.dev/docs/sharing/versioned)
- [All comparison guides](https://rolebook.dev/compare)
