Repository navigation
feat(policy): DSPX-2998 optionally namespace resource mappings #3567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
3accfa8
feat(policy): DSPX-2998 optionally namespace resource mappings
alkalescent 6a40277
feat(policy): DSPX-2998 backfill resource mapping namespaces from groups
alkalescent 011c840
feat(policy): DSPX-2998 resolve resource mapping group namespace by fqn
alkalescent 60b26a4
test(policy): DSPX-2998 strengthen ns filter test, move backfill to m…
alkalescent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
26 changes: 26 additions & 0 deletions
26
service/policy/db/migrations/20260604000000_add_namespace_to_resource_mappings.sql
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| -- +goose Up | ||
| -- +goose StatementBegin | ||
|
|
||
| -- Add a nullable owning namespace to resource mappings so they can be optionally | ||
| -- namespaced (owned by a tenant), independent of the namespace of the attribute | ||
| -- value they map. When a mapping belongs to a group, this matches the group's | ||
| -- namespace; ungrouped/legacy mappings leave it NULL. | ||
| ALTER TABLE resource_mappings | ||
| ADD COLUMN namespace_id UUID REFERENCES attribute_namespaces(id) ON DELETE CASCADE; | ||
|
|
||
| COMMENT ON COLUMN resource_mappings.namespace_id IS 'Optional owning namespace of the resource mapping. If the mapping belongs to a group, it matches the group namespace. The mapped attribute value may belong to a different namespace.'; | ||
|
|
||
| -- Index for namespace-scoped resource mapping queries. | ||
| CREATE INDEX idx_resource_mappings_namespace_id | ||
| ON resource_mappings(namespace_id); | ||
|
|
||
| -- +goose StatementEnd | ||
|
|
||
| -- +goose Down | ||
| -- +goose StatementBegin | ||
|
|
||
| DROP INDEX IF EXISTS idx_resource_mappings_namespace_id; | ||
|
|
||
| ALTER TABLE resource_mappings DROP COLUMN IF EXISTS namespace_id; | ||
|
|
||
| -- +goose StatementEnd |
25 changes: 25 additions & 0 deletions
25
service/policy/db/migrations/20260605000000_backfill_resource_mapping_namespace.sql
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| -- +goose Up | ||
| -- +goose StatementBegin | ||
|
|
||
| -- Backfill the owning namespace for existing grouped resource mappings created | ||
| -- before resource_mappings.namespace_id existed, so that namespace filtering | ||
| -- works on legacy data. A grouped mapping is owned by its group's namespace. | ||
| -- Ungrouped mappings have no group to derive ownership from and remain global | ||
| -- (namespace_id stays NULL). Idempotent: only fills rows that are still NULL. | ||
| UPDATE resource_mappings m | ||
| SET namespace_id = g.namespace_id | ||
| FROM resource_mapping_groups g | ||
| WHERE m.group_id = g.id | ||
| AND m.namespace_id IS NULL; | ||
|
|
||
| -- +goose StatementEnd | ||
|
|
||
| -- +goose Down | ||
| -- +goose StatementBegin | ||
|
|
||
| -- No-op: a backfilled namespace_id cannot be reliably distinguished from one set | ||
| -- intentionally after this migration, so the backfill is not reverted. The | ||
| -- column itself is removed by the add-namespace migration's down step. | ||
| SELECT 1; | ||
|
|
||
| -- +goose StatementEnd |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.