feat(database): add workspace derivation for project tables#368
Merged
Conversation
3fc715e to
1c8d468
Compare
Citus preparation needs project-domain records to carry a stable tenant key on new writes. Add workspace_id fields, derivation helpers, and create hooks for project publications, events, activity, comments, versions, share links, and extension records. New model writes can now resolve workspace ownership without startup-time compatibility backfills.
Collaboration documents and update batches need an explicit tenant key before distributed storage planning. Add workspace_id columns and create hooks that derive ownership from the document or owner for new records. Collab model writes now expose stable workspace routing data without legacy backfill code.
Partition target tables should match the new tenant-aware event and collaboration models. Add workspace_id to the fresh monthly event and hash-partitioned collab batch DDL and column lists. New Postgres schemas now create partitioned tables with tenant routing columns from the start.
Project service writes need to preserve the tenant key when creating collaboration documents and platform selections. Pass the resolved project workspace through access, collaboration, lifecycle, and publication-selection paths. Project-owned rows now receive workspace ownership at write time instead of relying on schema repair.
Project experience records need consistent tenant ownership for comments, versions, and activity history. Resolve accessible project workspace data once and stamp new activity, comment, and version rows with it. Experience APIs now write and query project-domain data with explicit workspace scope.
Project share links need tenant ownership for Citus routing and acceptance checks. Stamp share links with the project workspace and validate accepted links against the resolved project tenant. Share-link access now keeps project ownership explicit on both creation and acceptance paths.
Publish facts and read-model joins need the same tenant key as their owning project. Derive workspace_id when recording publish events and project activity, and include workspace scope in publication counts. Publish-derived rows now remain colocatable with project workspace data.
Extension callback tokens and execution events need tenant ownership for future distributed routing. Resolve the project workspace before creating handoff tokens and execution audit events. Extension handoff records now carry workspace_id on new writes.
Collaboration persistence writes rows outside the normal GORM model path and must provide tenant ownership directly. Stamp standalone documents with personal workspace ids and pass project or document workspace ids through direct SQL state and batch writes. Collab storage now writes tenant routing data consistently across Go and Node paths.
The new tenant columns need regression coverage in schema tests and existing SQL fixtures. Assert project-domain workspace columns and derivation on new rows, then update dashboard, publish, and helper fixtures for non-null workspace ids. Backend tests now exercise the clean target schema without historical compatibility backfills.
Archive tests insert partitioned event rows that now require workspace ownership. Add workspace_id values to archive partition and worker event fixtures. Archive coverage remains aligned with the tenant-aware event schema.
Direct collab-service SQL writes now provide workspace ids and need matching query expectations. Update persistence tests for project workspace lookup, state writes, and update batch workspace parameters. The Node persistence path is covered for tenant-aware collaboration storage.
The Citus preparation checklist now reflects workspace_id coverage for project-domain data. Mark the completed Phase 5 item and list model, partition, service, and test verification points. The plan now leaves colocation, constraints, and worker payload routing as the remaining work.
1c8d468 to
a4e3af8
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
Implementation Approach
Testing
go test ./...pnpm --dir collab-service test src/persistence/document-persistence.test.tspnpm --dir collab-service run type-checkpnpm --dir collab-service run lint