You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RegistryOrganization, RegistryLocation, RegistryAsset, and RegistryProject models have an externalId column representing keys in external systems. However, different external systems may share identical IDs. Since there was no provider dimension on the registry tables, data integrity was lost if identical externalId values collided across different providers.
Solution
Schema Modifications: Added a provider String? column to all four models (RegistryOrganization, RegistryLocation, RegistryAsset, and RegistryProject) in schema.prisma.
Scoped Uniqueness Constraint: Replaced the index setups on those models with a composite unique constraint @@unique([provider, externalId]).
Database Migration: Generated and applied the SQLite migration SQL file adding the columns and creating unique indexes.
Validation Tests: Added unit tests verifying that seeding registry entities with the same externalId from different providers is accepted, whereas seeding them with the same externalId and the same provider throws a uniqueness constraint violation.
Verification
Added a new integration test suite test/registry-uniqueness.spec.ts asserting the constraints on all four models.
All tests passed successfully:
accepts seeding two organizations with the same externalId from different providers (Passed)
rejects seeding two organizations with the same externalId from the same provider (Passed)
verifies the uniqueness constraint on other registry models (Location, Asset, Project) (Passed)
👋 Thanks for the contribution! This PR contains code/test changes and CI workflows were never auto-triggered (a GitHub Actions safety requirement for cross-repo forks). To unblock this for merging, a maintainer needs to either:\n\n1. Manually click 'Approve and run workflows' on this PR's Actions tab via the GitHub UI, or\n2. Approve the pending CI on the PR checks page.\n\nOnce the CI checks pass, this can be merged. 🚀
👋 Thanks for the contribution! This PR contains code/test changes and CI workflows were never auto-triggered (a GitHub Actions safety requirement for cross-repo forks). To unblock this for merging, a maintainer needs to either:\n\n1. Manually click 'Approve and run workflows' on this PR's Actions tab via the GitHub UI, or\n2. Approve the pending CI on the PR checks page.\n\nOnce the CI checks pass, this can be merged. 🚀
check please
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
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.
Closes #259
Problem Statement
RegistryOrganization,RegistryLocation,RegistryAsset, andRegistryProjectmodels have anexternalIdcolumn representing keys in external systems. However, different external systems may share identical IDs. Since there was noproviderdimension on the registry tables, data integrity was lost if identicalexternalIdvalues collided across different providers.Solution
provider String?column to all four models (RegistryOrganization,RegistryLocation,RegistryAsset, andRegistryProject) inschema.prisma.@@unique([provider, externalId]).externalIdfrom different providers is accepted, whereas seeding them with the sameexternalIdand the same provider throws a uniqueness constraint violation.Verification
test/registry-uniqueness.spec.tsasserting the constraints on all four models.accepts seeding two organizations with the same externalId from different providers(Passed)rejects seeding two organizations with the same externalId from the same provider(Passed)verifies the uniqueness constraint on other registry models (Location, Asset, Project)(Passed)