feat(pgpm): subsystem substitution in apply — exclude, rebind, cascade-safe materialization - #1530
Merged
Merged
Conversation
…e-safe materialization
Contributor
🤖 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:
|
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
Makes
applyable to substitute a subsystem: import a source package but drop one of its schemas wholesale, rebinding every surviving reference onto a replacement provider (an ordinary pgpm module deployed viarequires). The final glue over #1528 (routing profile) + #1529 (exclusion analysis) +@pgsql/transform@18.7.0(name rebinding).Spec surface (
pgpm.apply.json/ workspaceportabilityprofile):{ "source": "crm-module", "schemas": { "app": "crm" }, "exclude": { "schemas": ["identity"] }, // NEW "route": [ { "fromSchema": "identity", "kind": "table", "name": "users", "toSchema": "app_auth" }, // move FK targets { "fromSchema": "identity", "kind": "function", "name": "current_actor", "toSchema": "app_auth", "toName": "current_user_id" } // NEW: rebind to a different object ], "requires": ["auth-provider"] }Route entries now take
toSchema?: string | null(null= emit unqualified, resolve viasearch_path) and/ortoName?: string(rebind to a different object) — previously only a requiredtoSchema: string.Materialization (
materializeApplyModule): whenexcludeis present,excludeSubsystem): every surviving reference into an excluded schema must have a route/rebind target, else refuse with each unsatisfied object named (FK targets flagged);stripSubsystemSql, survivors byte-exact), plus provably subsystem-targeted opaque statements (DROP/COMMENT ONthem);New in
@pgpmjs/slice:stripSubsystemSql(analysis + statement removal in one pass) andblankScriptSql.Tested end-to-end on live PG (
__fixtures__/apply/substitution, vendor-neutral): acrm-modulewith anidentitysubsystem is applied withidentityexcluded — its FK and RLS-policy accessor rebound onto an installedauth-providermodule — then deploy/verify/revert all pass; the refusal path is asserted too. types 6 / transform 31 / slice 48 / bundle 52 / core 459 tests green.Link to Devin session: https://app.devin.ai/sessions/025fb88043964fdbb335ac5e39df2478
Requested by: @pyramation