Skip to content

feat(cells): Add organization avatar to control silo#113008

Open
lynnagara wants to merge 4 commits intomasterfrom
org-avatar-migration
Open

feat(cells): Add organization avatar to control silo#113008
lynnagara wants to merge 4 commits intomasterfrom
org-avatar-migration

Conversation

@lynnagara
Copy link
Copy Markdown
Member

In order to support moving org listing endpoint to the control silo, we need avatar data available without crossing silo boundaries.

This change adds avatar_type and avatar_ident columns to sentry_organizationmapping so the control silo can easily serve the avatar data. The replication logic will be added as a follow up - this PR just contains the schema migration.

In order to support moving org listing endpoint to the control silo, we need
avatar data available without crossing silo boundaries.

This change adds `avatar_type` and `avatar_ident` columns to `sentry_organizationmapping`
so the control silo can easily serve the avatar data. The replication logic will be
added as a follow up - this PR just contains the schema migration.
@lynnagara lynnagara requested a review from a team April 14, 2026 23:44
@lynnagara lynnagara requested review from a team as code owners April 14, 2026 23:44
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 14, 2026
@github-actions
Copy link
Copy Markdown
Contributor

This PR has a migration; here is the generated SQL for src/sentry/migrations/1068_add_avatar_to_organizationmapping.py

for 1068_add_avatar_to_organizationmapping in sentry

--
-- Add field avatar_ident to organizationmapping
--
ALTER TABLE "sentry_organizationmapping" ADD COLUMN "avatar_ident" varchar(32) DEFAULT NULL NULL;
--
-- Add field avatar_type to organizationmapping
--
ALTER TABLE "sentry_organizationmapping" ADD COLUMN "avatar_type" smallint DEFAULT 0 NOT NULL CHECK ("avatar_type" >= 0);

Comment on lines +59 to +61
# Replicated from OrganizationAvatar in the cell silo
avatar_type = models.PositiveSmallIntegerField(default=0, db_default=0)
avatar_ident = models.CharField(max_length=32, null=True, db_default=None)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Having these fields here is convenient as we don't have more tables to manage, but it also means that upserts from cells are slightly more complicated as we have to read the avatar record and include it as well.

Another approach would be to separate the avatar into a dedicated replicated model. That would allow us to replicate state independently and have simpler logic to handle updates and deletes.

Copy link
Copy Markdown
Member Author

@lynnagara lynnagara Apr 16, 2026

Choose a reason for hiding this comment

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

I think the upsert/delete implementation might be about the same either way as both ways would hook into the same two OrganizationAvatar functions - handle_async_replication and handle_async_deletion. With the orgmapping you get org deletion cascades for free, as well as the 1:1 relationship between avatar and orgs structurally enforced. Having said that HybridCloudForeignKey seems to handle that anyway so it's not really a big deal.

Separate table seems to more closely match patterns in the rest of the hybrid cloud codebase, so i switched this migration out to do it that way.

The new table contains the organization ID as the only hybrid cloud foreign key (it's already a snowflake id, so the only one guaranteed to be globally unique) with the unique=True constraint. The original primary key from the OrganizationAvatar model is not replicated to control as it is not guaranteed to be globally unique -- it's easier to base replication logic, etc, on the org id in this case.

@lynnagara lynnagara changed the title feat(cells): Add avatar fields to OrganizationMapping feat(cells): Add avatar fields to control silo Apr 15, 2026
@lynnagara lynnagara changed the title feat(cells): Add avatar fields to control silo feat(cells): Add organization avatar to control silo Apr 15, 2026
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 69b7b89. Configure here.

Comment thread src/sentry/models/organizationavatareplica.py Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 16, 2026

This PR has a migration; here is the generated SQL for src/sentry/migrations/1068_add_organization_avatar_replica.py

for 1068_add_organization_avatar_replica in sentry

--
-- Create model OrganizationAvatarReplica
--
CREATE TABLE "sentry_organizationavatarreplica" ("id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, "organization_id" bigint NOT NULL UNIQUE, "avatar_type" smallint NOT NULL CHECK ("avatar_type" >= 0), "avatar_ident" varchar(32) NOT NULL);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants