Repository navigation
Conversation
Postgres rejects a rename to the current name ("schema/role already exists",
"policy ... already exists"), which rolled back the whole update when a
client sent the unchanged name with other fields. Tables, columns, triggers
and functions already skip the no-op rename (supabase#44).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
breken-ai
requested review from
a team,
avallete and
soedirgo
as code owners
September 26, 2026 03:55
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
Bug fix
What is the current behavior?
If you
PATCHa schema, role or policy and include the name it already has, the whole update fails. The endpoints arePATCH /schemas/:id,PATCH /roles/:idandPATCH /policies/:id. This happens, for example, when a form sends every field back unchanged and only edits the owner,can_loginor the policy definition.update()always emits a rename whennameis set, and Postgres rejects a rename to the current name:The rename is in the same transaction as the other changes, so they are rolled back as well. The API returns that error.
Tables, columns, triggers, functions and publications already skip the rename when the name is unchanged (#44 did this for tables and columns).
What is the new behavior?
PostgresMetaSchemas.update,PostgresMetaRoles.updateandPostgresMetaPolicies.updateonly emit the rename whennamediffers from the current name. This is the same check used inPostgresMetaTables.Additional context
I added an
update with name unchangedtest totest/lib/schemas.ts,test/lib/roles.tsandtest/lib/policies.ts. Each one sends the same name together with another change.master, all 3 fail with the errors above. For example,"message": "role \"r_same_name\" already exists".test/index.test.tspasses 150/150 against thetest/dbimage (supabase/postgres:14.1.0).npm run checkandprettier -care clean.This PR was prepared with an AI coding assistant (Claude Code). I reproduced the failure and ran the tests against a real Postgres.
🤖 Generated with Claude Code