Skip to content

feat(database): add workspace derivation for project tables#368

Merged
KurodaKayn merged 14 commits into
mainfrom
feat/citus-workspace-derivation
Jun 28, 2026
Merged

feat(database): add workspace derivation for project tables#368
KurodaKayn merged 14 commits into
mainfrom
feat/citus-workspace-derivation

Conversation

@KurodaKayn

@KurodaKayn KurodaKayn commented Jun 28, 2026

Copy link
Copy Markdown
Owner

Feature Description

  • Adds explicit or derived workspace_id coverage for project-domain publishing, activity, collaboration, share-link, and extension records.
  • Keeps the implementation focused on clean target schema and new write paths; no startup-time legacy backfill or compatibility migration is included.
  • Updates the Phase 5 Citus preparation plan with verification entry points.

Implementation Approach

  • Adds model fields/hooks and service-level workspace stamping for project_id/document_id ownership derivation.
  • Updates monthly/hash partition target DDL and collab-service direct SQL persistence to write workspace_id from the start.
  • Keeps constraint/colocation design and worker payload routing as remaining Phase 5 work.

Testing

  • go test ./...
  • pnpm --dir collab-service test src/persistence/document-persistence.test.ts
  • pnpm --dir collab-service run type-check
  • pnpm --dir collab-service run lint

@KurodaKayn KurodaKayn force-pushed the feat/citus-workspace-derivation branch from 3fc715e to 1c8d468 Compare June 28, 2026 13:54
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.
@KurodaKayn KurodaKayn force-pushed the feat/citus-workspace-derivation branch from 1c8d468 to a4e3af8 Compare June 28, 2026 14:23
@KurodaKayn KurodaKayn merged commit b547974 into main Jun 28, 2026
15 checks passed
@KurodaKayn KurodaKayn deleted the feat/citus-workspace-derivation branch June 28, 2026 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant