feat(database): derive workspace ids for project rows#369
Merged
Conversation
The core models file mixed type declarations with persistence lifecycle behavior, making later model changes harder to review. Move the existing non-AI BeforeCreate hooks into a dedicated hooks file without changing their behavior. This leaves models.go focused on declarations while preserving the same GORM lifecycle defaults.
Citus preparation needs non-AI project-domain rows to carry stable tenant routing data even when callers omit it. Derive workspace IDs for media assets, media usages, and scheduled publications from their project or media ownership path. This keeps those rows colocatable by workspace_id without mixing in AI-specific model behavior.
AI project-domain records also need stable tenant routing before Citus distribution can be introduced. Add AI-specific lifecycle hooks that stamp workspace IDs from the owning project when callers omit the field. Keeping these hooks separate from generic model hooks makes the AI persistence behavior easier to review.
The new model hooks need regression coverage so direct inserts keep tenant routing data. Extend the database derivation test across scheduled publishing, media rows, and AI project-domain records. The assertions verify each row resolves workspace_id through its stable project or media relationship.
The database optimization plan should point to the implemented workspace derivation evidence. Update the tenant boundary and Citus preparation entries to reference generic and AI hook files plus database tests. This keeps the Phase 5 checklist aligned with the separated model and AI implementation.
2b72e91 to
92de6f1
Compare
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.
Feature Description
workspace_idfrom stable ownership paths.Implementation Approach
Testing
bash script/ci/backend.sh.container-images.ymlbecause it is a heavier PR workflow check than the backend CI equivalent.