Skip to content

SITES-49202: remove deprecated brand semrushWorkspaceId mirror (§5 PR B, spacecat-shared) - #1867

Open
aliciadriani wants to merge 5 commits into
mainfrom
SITES-49202-remove-brand-semrushworkspaceid-shared
Open

SITES-49202: remove deprecated brand semrushWorkspaceId mirror (§5 PR B, spacecat-shared)#1867
aliciadriani wants to merge 5 commits into
mainfrom
SITES-49202-remove-brand-semrushworkspaceid-shared

Conversation

@aliciadriani

@aliciadriani aliciadriani commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

What & why

PR B of the phased §5 Serenity post-GA cleanup — removes the deprecated, read-only brand semrushWorkspaceId mirror from @adobe/spacecat-shared-data-access.

This mirror shadowed the canonical semrushSubWorkspaceId (write-of-record) and was maintained by the mysticat-data-service brands_sync_semrush_workspace_id DB trigger. Now that PR A (project-elmo-ui #2730, merged) migrated the last direct reader, the mirror can go.

Precondition (verified before removal)

  • Prod DB: 0 rows where the brand mirror is the only value (carries no unique data).
  • No backend caller of the brand finder/setter. Grepped origin/main of spacecat-shared, spacecat-api-service, llmo-data-retrieval-service, project-elmo-ui, mysticat-data-service for findBySemrushWorkspaceId / allBySemrushWorkspaceId / setSemrushWorkspaceId / brand-context getSemrushWorkspaceId( — every hit is org-context (Organization / org. / organization.) or design-spec prose. No genuine brand-context reader.

Datastore / index note — NO infra op (corrected)

An earlier version of this description flagged a "DynamoDB GSI infra review". That was wrong and is retracted.

This data-access layer is PostgREST/Postgres-backed (base.collection.jsstatic DATASTORE_TYPE = DATASTORE_TYPE.POSTGREST, @supabase/postgrest-js, POSTGREST_URL). Despite the legacy electrodb-style gsi{N}pk / addAllIndex naming in schema.builder.js, there is no DynamoDB table or GSI here — verified directly against spacecat-infrastructure (which provisions the Mysticat Postgres service + one unrelated github-service lock table, no spacecat data table with brand GSIs).

Removing addAllIndex(['semrushWorkspaceId']) just stops the data-access layer generating the semrushWorkspaceId finder — no infra/table change, and none needed. The one physical artifact is the Postgres unique index brands_semrush_workspace_id_key ON brands(semrush_workspace_id) (confirmed live on prod), which drops automatically with the column in PR C (mysticat-data-service migration). So this PR is code-only with no infra dependency.

org-level field deliberately KEPT

Organization.semrushWorkspaceId (correctly-named, distinct entity) is untouched — this is a brand-only removal. The symbol collision is the trap here; org getter/finder/setter all stay.

Changes (brand model only)

File Change
src/models/brand/brand.schema.js Removed the semrushWorkspaceId readOnly mirror attribute and addAllIndex(['semrushWorkspaceId']); tidied surrounding comments.
src/models/brand/brand.model.js Removed the @deprecated setSemrushWorkspaceId() BC delegate + docblock; updated the class docblock to describe semrushSubWorkspaceId as the dual-mode switch.
src/models/brand/brand.collection.js Updated docblock: pointer-repair path now references findBySemrushSubWorkspaceId.
src/models/brand/index.d.ts Removed the mirror type decls: getSemrushWorkspaceId, setSemrushWorkspaceId, allBySemrushWorkspaceId, findBySemrushWorkspaceId.
test/unit/models/brand/brand.schema.test.js Removed the deprecated-mirror attribute describe block.
test/unit/models/brand/brand.model.test.js Removed the deprecated-mirror getter/setter describe block and the fixture field.
test/unit/models/brand/brand.collection.test.js Removed the mirror index-accessor assertion and the fixture field.

Next step — PR C (do NOT land before this releases)

PR C = mysticat-data-service migration dropping the brands.semrush_workspace_id column and the sync_semrush_workspace_id_from_sub trigger (the Postgres unique index brands_semrush_workspace_id_key drops with the column). It must land only AFTER this PR is released/deployed, so no deployed consumer still references the mirror attribute when the column/trigger disappear.

Semver

Published package — this removes public model members, so a semver bump is expected and handled by semantic-release from the conventional-commit message. No manual version edits.

Validation

  • npm run lint (data-access): clean.
  • npm test (data-access, full unit suite): 2774 passing, 0 failing.

Links

…SITES-49202)

§5 PR B of the Serenity post-GA cleanup. Removes the deprecated, read-only
`semrushWorkspaceId` mirror attribute from the Brand model (mysticat-data-service
`brands.semrush_workspace_id`), now that project-elmo-ui PR #2730 (PR A) has
migrated the last direct reader to the canonical `semrushSubWorkspaceId`.

Precondition (verified): the brand mirror carries no unique data (prod DB: 0 rows
where it is the only value) and has no backend caller of its finder/setter. The
org-level `Organization.semrushWorkspaceId` is a distinct, correctly-named field
and is deliberately KEPT.

Removed (brand model only):
- brand.schema.js: the `semrushWorkspaceId` readOnly attribute and its
  `addAllIndex(['semrushWorkspaceId'])`.
- brand.model.js: the @deprecated `setSemrushWorkspaceId()` BC delegate + docblock.
- brand.collection.js / index.d.ts: the mirror finder references and type
  declarations (get/set/findBy/allBySemrushWorkspaceId).
- brand unit tests: the corresponding mirror assertions/fixtures.

Note: `addAllIndex(['semrushWorkspaceId'])` defines a DynamoDB GSI in the electrodb
schema — this change stops the code using it, but the physical GSI teardown is a
separate infra op and needs DynamoDB review before merge+deploy.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@aliciadriani aliciadriani left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review — §5 PR B (manual)

Summary

Removes the deprecated brand semrushWorkspaceId mirror (readOnly attribute, its addAllIndex GSI, the @deprecated setSemrushWorkspaceId() delegate, and the finder/getter type decls) from the electrodb Brand model. Consistent and well-scoped; the org-level field is correctly left alone.

Must Fix

None.

Should Fix

None.

Nits

None material. The brand.collection.js pointer-repair docblock now points at findBySemrushSubWorkspaceId — verified that finder is generated from the retained addAllIndex(['semrushSubWorkspaceId']), so the doc is accurate.

What's Good

  • Pre-removal grep across spacecat-shared / spacecat-api-service / llmo-data-retrieval-service / project-elmo-ui / mysticat-data-service found no brand-context reader — every hit was the org field or design-spec prose. Precondition solid.
  • Reads of existing DynamoDB items are unaffected (electrodb ignores stored fields absent from the schema); the attribute was readOnly, so nothing wrote through it.
  • 2774 data-access unit tests pass; lint clean.
  • PR body correctly flags the DynamoDB GSI infra-review gate, the PR C ordering (must land after this releases), and the semver bump.

@aliciadriani
aliciadriani marked this pull request as ready for review August 6, 2026 14:16

@aliciadriani aliciadriani left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DynamoDB GSI infra review — CLEARED (safe to merge; no infra change needed)

TL;DR: removing addAllIndex(['semrushWorkspaceId']) is safe with no Terraform/GSI teardown required, because the electrodb Brand entity is not populated — nothing anywhere writes or reads it.

What I checked

  1. Is the entity used? Grepped all 5 repos (spacecat-shared, spacecat-api-service, llmo-data-retrieval-service, project-elmo-ui, mysticat-data-service) for dataAccess.Brand reads/writes/queries → zero. Serenity brands live in mysticat-data-service Postgres via PostgREST (brands-storage.js), never the electrodb Brand model. So there are no Brand items in DynamoDB.
  2. Does removal renumber the GSIs? Yes. schema.builder.js assigns physical gsi{N}pk/sk by index insertion order. On main Brand has two all-indexes (semrushWorkspaceId=gsi1, semrushSubWorkspaceId=gsi2); after removal semrushSubWorkspaceId shifts to gsi1 (empirically confirmed: PR branch builds gsi1 only). On a populated entity this would orphan existing items' GSI-projected data and break findBySemrushSubWorkspaceId — but per (1) the entity is empty, so zero runtime impact.
  3. Physical GSI teardown? Not applicable. This is a shared single-table design — physical gsi1..gsi5 are shared across all entities (Site/Org/…) and stay provisioned. Removing Brand's logical index doesn't delete any physical GSI. There is no dedicated brand GSI to tear down.

Verdict

Infra-safe to merge. The PR body's "physical GSI teardown is a separate infra op" caveat can be downgraded — no such op exists here.

One caveat + a follow-up

  • I could not inspect spacecat-infrastructure directly (not checked out). Evidence strongly indicates standard shared gsi1-5; a 30-sec confirm from the table owner that no dedicated brand GSI is provisioned would make this airtight.
  • Bigger picture: the electrodb Brand entity appears entirely dead (unused everywhere). Worth a separate follow-up to consider removing the whole model — out of scope for §5.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

This PR will trigger a patch release when merged.

@aliciadriani aliciadriani left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • spacecat-shared-data-access is PostgREST/Postgres-backed, not DynamoDB. base.collection.js:53 is static DATASTORE_TYPE = DATASTORE_TYPE.POSTGREST; the layer requires POSTGREST_URL/POSTGREST_SCHEMA/POSTGREST_API_KEY and queries via @supabase/postgrest-js (postgrestService.from(tableName)). The gsi{N}pk / addAllIndex naming in schema.builder.js is a legacy electrodb vestige — no DynamoDB table or GSI is involved.
  • spacecat-infrastructure has no spacecat data table with brand GSIs — it provisions the Mysticat Postgres data service and one unrelated mysticat_github_service idempotency lock table. There is no DynamoDB GSI to review or tear down.
  • The real physical artifact behind findBySemrushWorkspaceId is a Postgres UNIQUE indexbrands_semrush_workspace_id_key ON brands (semrush_workspace_id), confirmed present on prod right now. It is dropped automatically when §5 PR C drops the brands.semrush_workspace_id column (mysticat-data-service migration). Nothing to do in Terraform/DynamoDB.

Net

This PR is a code-only schema/finder removal with NO infra dependency — it just stops the data-access layer generating the semrushWorkspaceId finder. The prior "DynamoDB GSI teardown is a separate infra op" flag in the PR body is retracted — no such op exists. The only physical cleanup (the Postgres index) rides along with §5 PR C.

The renumbering note from my earlier comment is also moot (and was DynamoDB-specific); disregard it.

@aliciadriani aliciadriani self-assigned this Aug 6, 2026
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