Skip to content

fix: standalone compat for platform_secrets ON CONFLICT#61

Open
pyramation wants to merge 3 commits into
feat/constructive-infra-schemafrom
feat/standalone-secrets-compat
Open

fix: standalone compat for platform_secrets ON CONFLICT#61
pyramation wants to merge 3 commits into
feat/constructive-infra-schemafrom
feat/standalone-secrets-compat

Conversation

@pyramation
Copy link
Copy Markdown
Contributor

@pyramation pyramation commented Jun 8, 2026

Summary

Standalone compatibility patch for the platform_secrets ON CONFLICT mismatch: the generated platform_secrets_set() uses ON 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 generated constructive-infra-seed package. This way re-slicing never clobbers hand-written SQL.

The patch itself:

  1. ALTER COLUMN database_id SET DEFAULT jwt_private.current_database_id() — so INSERTs without explicit database_id still work
  2. CREATE UNIQUE INDEX (namespace_id, name) — matches the ON CONFLICT clause

Deploy order: constructive-infraconstructive-infra-seedstandalone-patches

Link to Devin session: https://app.devin.ai/sessions/e4d315e507cf4d95ac42056ad22b8925
Requested by: @pyramation

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-integration
Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant