Skip to content

Commit 9b0da32

Browse files
DominikB2014shayna-ch
authored andcommitted
ref(explore): Remove last_received from attribute context tables (#118562)
Removes `last_received` from the `TraceItemAttributeContext` and `TraceItemAttributeValueContext` tables. We're going to retrieve `last_received` from ClickHouse instead (getsentry/snuba#7801), so there's no need to store it. These tables are completely empty, so the column can be dropped without any data concerns. Fixes [BROWSE-587](https://linear.app/getsentry/issue/BROWSE-587/remove-last-received-from-attribute-context-tables)
1 parent 604407d commit 9b0da32

4 files changed

Lines changed: 39 additions & 7 deletions

File tree

migrations_lockfile.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ will then be regenerated, and you should be able to merge without conflicts.
77

88
discover: 0003_discover_json_field
99

10-
explore: 0009_add_trace_item_attribute_value_context
10+
explore: 0010_remove_last_received_from_attribute_context
1111

1212
feedback: 0007_cleanup_failed_safe_deletes
1313

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Generated by Django 5.2.14 on 2026-06-26 14:35
2+
3+
from sentry.new_migrations.migrations import CheckedMigration
4+
from sentry.new_migrations.monkey.fields import SafeRemoveField
5+
from sentry.new_migrations.monkey.state import DeletionAction
6+
7+
8+
class Migration(CheckedMigration):
9+
# This flag is used to mark that a migration shouldn't be automatically run in production.
10+
# This should only be used for operations where it's safe to run the migration after your
11+
# code has deployed. So this should not be used for most operations that alter the schema
12+
# of a table.
13+
# Here are some things that make sense to mark as post deployment:
14+
# - Large data migrations. Typically we want these to be run manually so that they can be
15+
# monitored and not block the deploy for a long period of time while they run.
16+
# - Adding indexes to large tables. Since this can take a long time, we'd generally prefer to
17+
# run this outside deployments so that we don't block them. Note that while adding an index
18+
# is a schema change, it's completely safe to run the operation after the code has deployed.
19+
# Once deployed, run these manually via: https://develop.sentry.dev/database-migrations/#migration-deployment
20+
21+
is_post_deployment = False
22+
23+
dependencies = [
24+
("explore", "0009_add_trace_item_attribute_value_context"),
25+
]
26+
27+
operations = [
28+
SafeRemoveField(
29+
model_name="traceitemattributecontext",
30+
name="last_received",
31+
deletion_action=DeletionAction.MOVE_TO_PENDING,
32+
),
33+
SafeRemoveField(
34+
model_name="traceitemattributevaluecontext",
35+
name="last_received",
36+
deletion_action=DeletionAction.MOVE_TO_PENDING,
37+
),
38+
]

src/sentry/explore/models.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,6 @@ class TraceItemAttributeContext(DefaultFieldsModel):
451451

452452
created_by_id = HybridCloudForeignKey("sentry.User", null=True, on_delete="SET_NULL")
453453
updated_by_id = HybridCloudForeignKey("sentry.User", null=True, on_delete="SET_NULL")
454-
# When the attribute was last seen in storage. Used to prune stale attributes.
455-
last_received = models.DateTimeField(null=True)
456454

457455
class Meta:
458456
app_label = "explore"
@@ -512,8 +510,6 @@ class TraceItemAttributeValueContext(DefaultFieldsModel):
512510

513511
created_by_id = HybridCloudForeignKey("sentry.User", null=True, on_delete="SET_NULL")
514512
updated_by_id = HybridCloudForeignKey("sentry.User", null=True, on_delete="SET_NULL")
515-
# When the value was last seen in storage. Used to prune stale entries.
516-
last_received = models.DateTimeField(null=True)
517513

518514
class Meta:
519515
app_label = "explore"

tests/sentry/explore/test_models.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ def test_create_project_scoped(self) -> None:
4646
assert description.id is not None
4747
assert description.examples == ["GET", "POST"]
4848
assert description.additional_context is None
49-
assert description.last_received is None
5049

5150
def test_create_org_wide(self) -> None:
5251
description = TraceItemAttributeContext.objects.create(
@@ -156,7 +155,6 @@ def test_create_project_scoped(self) -> None:
156155
)
157156
assert context.id is not None
158157
assert context.additional_context is None
159-
assert context.last_received is None
160158

161159
def test_create_org_wide(self) -> None:
162160
context = TraceItemAttributeValueContext.objects.create(

0 commit comments

Comments
 (0)