Skip to content

Commit 69b7b89

Browse files
committed
make a separate table
1 parent 57b4d2b commit 69b7b89

File tree

6 files changed

+91
-43
lines changed

6 files changed

+91
-43
lines changed

migrations_lockfile.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ replays: 0007_organizationmember_replay_access
3131

3232
seer: 0006_add_night_shift_models
3333

34-
sentry: 1068_add_avatar_to_organizationmapping
34+
sentry: 1068_add_organization_avatar_replica
3535

3636
social_auth: 0003_social_auth_json_field
3737

src/sentry/migrations/1068_add_avatar_to_organizationmapping.py

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Generated by Django 5.2.12 on 2026-04-15 23:47
2+
3+
import sentry.db.models.fields.bounded
4+
import sentry.db.models.fields.hybrid_cloud_foreign_key
5+
from django.db import migrations, models
6+
7+
from sentry.new_migrations.migrations import CheckedMigration
8+
9+
10+
class Migration(CheckedMigration):
11+
# This flag is used to mark that a migration shouldn't be automatically run in production.
12+
# This should only be used for operations where it's safe to run the migration after your
13+
# code has deployed. So this should not be used for most operations that alter the schema
14+
# of a table.
15+
# Here are some things that make sense to mark as post deployment:
16+
# - Large data migrations. Typically we want these to be run manually so that they can be
17+
# monitored and not block the deploy for a long period of time while they run.
18+
# - Adding indexes to large tables. Since this can take a long time, we'd generally prefer to
19+
# run this outside deployments so that we don't block them. Note that while adding an index
20+
# is a schema change, it's completely safe to run the operation after the code has deployed.
21+
# Once deployed, run these manually via: https://develop.sentry.dev/database-migrations/#migration-deployment
22+
23+
is_post_deployment = False
24+
25+
dependencies = [
26+
("sentry", "1067_add_dashboard_revision_model"),
27+
]
28+
29+
operations = [
30+
migrations.CreateModel(
31+
name="OrganizationAvatarReplica",
32+
fields=[
33+
(
34+
"id",
35+
sentry.db.models.fields.bounded.BoundedBigAutoField(
36+
primary_key=True, serialize=False
37+
),
38+
),
39+
(
40+
"organization_avatar_id",
41+
sentry.db.models.fields.hybrid_cloud_foreign_key.HybridCloudForeignKey(
42+
"sentry.OrganizationAvatar",
43+
db_index=True,
44+
on_delete="CASCADE",
45+
unique=True,
46+
),
47+
),
48+
(
49+
"organization_id",
50+
sentry.db.models.fields.hybrid_cloud_foreign_key.HybridCloudForeignKey(
51+
"sentry.Organization",
52+
db_index=True,
53+
on_delete="CASCADE",
54+
unique=True,
55+
),
56+
),
57+
("avatar_type", models.PositiveSmallIntegerField(default=0)),
58+
("avatar_ident", models.CharField(max_length=32)),
59+
],
60+
options={
61+
"db_table": "sentry_organizationavatareplica",
62+
},
63+
),
64+
]

src/sentry/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
from .options import * # NOQA
7171
from .organization import * # NOQA
7272
from .organizationaccessrequest import * # NOQA
73+
from .organizationavatareplica import * # NOQA
7374
from .organizationcontributors import * # NOQA
7475
from .organizationmapping import * # NOQA
7576
from .organizationmember import * # NOQA
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from __future__ import annotations
2+
3+
from django.db import models
4+
5+
from sentry.backup.scopes import RelocationScope
6+
from sentry.db.models import Model, control_silo_model, sane_repr
7+
from sentry.db.models.fields.hybrid_cloud_foreign_key import HybridCloudForeignKey
8+
9+
10+
@control_silo_model
11+
class OrganizationAvatarReplica(Model):
12+
__relocation_scope__ = RelocationScope.Excluded
13+
14+
organization_avatar_id = HybridCloudForeignKey(
15+
"sentry.OrganizationAvatar", on_delete="CASCADE", unique=True
16+
)
17+
organization_id = HybridCloudForeignKey("sentry.Organization", on_delete="CASCADE", unique=True)
18+
avatar_type = models.PositiveSmallIntegerField(default=0)
19+
avatar_ident = models.CharField(max_length=32)
20+
21+
class Meta:
22+
app_label = "sentry"
23+
db_table = "sentry_organizationavatareplica"
24+
25+
__repr__ = sane_repr("organization_id", "avatar_type")

src/sentry/models/organizationmapping.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ class OrganizationMapping(Model):
5656
prevent_superuser_access = models.BooleanField(default=False, db_default=False)
5757
disable_member_invite = models.BooleanField(default=False, db_default=False)
5858

59-
# Replicated from OrganizationAvatar in the cell silo
60-
avatar_type = models.PositiveSmallIntegerField(default=0, db_default=0)
61-
avatar_ident = models.CharField(max_length=32, null=True, db_default=None)
62-
6359
date_updated = models.DateTimeField(db_default=Now(), auto_now=True)
6460

6561
class Meta:

0 commit comments

Comments
 (0)