Repository navigation
Add adopt_tenant_id: pin a legacy project's tenant (#112) - #115
Merged
Merged
Conversation
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.
Closes #112.
Adds
nw.adopt_tenant_id(project, *, dry_run=False): an explicit, idempotent one-shot that writes a legacy project's currently-resolved tenant (root+title hash, or song hash) intoproject.jsonastenant_id. The tenant, and so the data the project reads, is unchanged; the key just stops depending on root + title, so a folder removed and recreated by hand can no longer inherit the old Postgres graph. Projects that already have atenant_idare left alone; nw never calls it itself (the host or a migration command runs it, ideally while the project is intact, since the song-hash form reads the audio file). It adds one key toproject.json; no graph data is moved or deleted. Running it over a real deployment's existing projects is the host's call.Tests:
tests/test_tenant_id.py(pins the same tenant, idempotent, dry-run writes nothing, key survives retitle/move, non-project returns None). Full suite 761 passed.Independent review (fresh Opus): two confirmed problems, both fixed here: (1) a missing song file would have pinned the root+title fallback permanently, so adoption now raises
FileNotFoundErrorinstead; (2) a self-keyed storage (MappingStorage) has notenant_id, so adoption now returnsNonefor it. Noted, not changed: two legacy projects that share audio bytes already share one tenant and adoption keeps that. No path moves or deletes graph data.