Skip to content

feat(database): derive workspace ids for project rows#369

Merged
KurodaKayn merged 5 commits into
mainfrom
feat/citus-project-domain-routing
Jun 28, 2026
Merged

feat(database): derive workspace ids for project rows#369
KurodaKayn merged 5 commits into
mainfrom
feat/citus-project-domain-routing

Conversation

@KurodaKayn

Copy link
Copy Markdown
Owner

Feature Description

  • Complete the Phase 5 Citus prep item for stable workspace routing on project-domain rows.
  • Ensure direct inserts for scheduled publishing, media, and AI project records derive workspace_id from stable ownership paths.
  • Update the database optimization plan evidence to include the newly covered AI and media paths.

Implementation Approach

  • Add model hooks that derive workspace IDs from owning projects or media assets when callers omit the field.
  • Extend DB regression coverage for scheduled publications, media assets/usages, AI snapshots/runs/proposals, and drafting sessions.
  • Keep business code, tests, and docs in separate atomic commits.

Testing

  • Passed: bash script/ci/backend.sh.
  • Not run: local Docker image build from container-images.yml because it is a heavier PR workflow check than the backend CI equivalent.

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.
@KurodaKayn KurodaKayn force-pushed the feat/citus-project-domain-routing branch from 2b72e91 to 92de6f1 Compare June 28, 2026 14:54
@KurodaKayn KurodaKayn merged commit 2800ac8 into main Jun 28, 2026
14 checks passed
@KurodaKayn KurodaKayn deleted the feat/citus-project-domain-routing branch June 28, 2026 15:06
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