fix: standalone compat for platform_secrets ON CONFLICT#61
Open
pyramation wants to merge 3 commits into
Open
Conversation
The slicer-generated platform_secrets_set() does ON CONFLICT (namespace_id, name) but the table's unique constraint is (database_id, namespace_id, name). In the monolith this evolved across migrations; the slicer extracted the final table state but the function from the earlier schema. This seed patch bridges the gap for standalone mode: 1. DEFAULT on database_id from jwt_private.current_database_id() 2. Unique index on (namespace_id, name) matching the ON CONFLICT clause
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Hand-written SQL must live in a separate package from generated code so re-slicing never clobbers it. Moved the platform_secrets compat patch (DEFAULT database_id + unique index) from constructive-infra-seed into the new pgpm/standalone-patches/ package.
The seed package is already hand-written, so no need for a separate package. Dropped pgpm/standalone-patches/ and moved the patch back into constructive-infra-seed alongside the other seed migrations.
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.
Summary
Standalone compatibility patch for the
platform_secretsON CONFLICT mismatch: the generatedplatform_secrets_set()usesON CONFLICT (namespace_id, name)but the table's actual unique constraint is(database_id, namespace_id, name).Key change: Moved the hand-written patch into its own separate pgpm package (
pgpm/standalone-patches/) rather than putting it inside the generatedconstructive-infra-seedpackage. This way re-slicing never clobbers hand-written SQL.The patch itself:
ALTER COLUMN database_id SET DEFAULT jwt_private.current_database_id()— so INSERTs without explicit database_id still workCREATE UNIQUE INDEX (namespace_id, name)— matches the ON CONFLICT clauseDeploy order:
constructive-infra→constructive-infra-seed→standalone-patchesLink to Devin session: https://app.devin.ai/sessions/e4d315e507cf4d95ac42056ad22b8925
Requested by: @pyramation