fix(pgpm): add database_id filter to sql_actions export and skipSchemaRenaming option #556
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
This PR fixes a bug in the export pipeline where the
sql_actionsquery had noWHEREclause, causing it to export actions from ALL databases instead of just the target database. This could cause cross-database pollution in persistent database environments.Additionally, adds a new
skipSchemaRenamingoption to support self-referential introspection scenarios where infrastructure schema names (likemetaschema_public,services_public) should be preserved rather than renamed.Key changes:
WHERE database_id = $1filter to the sql_actions queryskipSchemaRenamingoption to bothExportMigrationsToDiskOptionsandExportOptionsinterfacesexportMigrationsandexportMigrationsToDiskfunctionsReview & Testing Checklist for Human
db_migrate.sql_actionstable has adatabase_idcolumn - the query assumes this column exists but it wasn't verified in the codebasepnpm generate:rlsor equivalent export command to verify the database_id filter doesn't break existing functionalityRecommended test plan:
Notes
This is Phase 1 of a larger plan to enable metaschema self-referential introspection for RLS policy generation. The
skipSchemaRenamingoption is added but not yet used by any callers - that will come in subsequent phases.Link to Devin run: https://app.devin.ai/sessions/23949faa112a4110a435a82d88fb47c1
Requested by: Dan Lynch (@pyramation)