payloadcms / payloadcms/payload
Multi-tenant: tenant deletion fails with DrizzleQueryError — transaction aborted (Postgres)
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 44.8k
- Forks
- 4.2k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 53
Description
Describe the Bug
Deleting a tenant in the multi-tenant plugin using the Postgres adapter fails. A Drizzle/Postgres error aborts the transaction.
{
"type": "DrizzleQueryError",
"message": "Failed query: delete from \"payload_preferences\" where \"payload_preferences\".\"key\" in ($1)\nparams: collection-tenants-3: current transaction is aborted, commands ignored until end of transaction block"
}
Link to the code that reproduces this issue
https://github.com/payloadcms/payload/tree/main/examples/multi-tenant
Reproduction Steps
- Clone the multi-tenant example.
- Configure the example to use Postgres (set DATABASE_URL to a Postgres DB) so @payloadcms/db-postgres is used.
- Start the project and log in to the admin.
- Create a tenant.
- Attempt to delete the tenant via the admin UI.
- Observe the delete fails and the transaction is aborted.
Which area(s) are affected? (Select all that apply)
plugin: multi-tenant, db: postgres
Environment Info
payload: 3.63.0
@payloadcms/plugin-multi-tenant: 3.63.0
@payloadcms/db-postgres: 3.63.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the examples/multi-tenant project, configure DATABASE_URL for Postgres, and reproduce tenant deletion through the admin UI. Then trace the multi-tenant plugin and @payloadcms/db-postgres transaction handling; done means the tenant deletes successfully without an aborted transaction and the regression is covered by an appropriate test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgres, typescript
- Domain
- backend, database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100