Skip to content

Commit

Permalink
ref: remove unused attachment_id column part 1 (#82892)
Browse files Browse the repository at this point in the history
blocked on #82891

<!-- Describe your PR here. -->
  • Loading branch information
asottile-sentry authored Jan 7, 2025
1 parent ec05a92 commit f6ce723
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 84 deletions.
2 changes: 1 addition & 1 deletion migrations_lockfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ remote_subscriptions: 0003_drop_remote_subscription

replays: 0004_index_together

sentry: 0805_add_alert_and_member_invite_scopes_to_sentry_apps
sentry: 0806_remove_monitor_attachment_id_pt1

social_auth: 0002_default_auto_field

Expand Down
33 changes: 33 additions & 0 deletions src/sentry/migrations/0806_remove_monitor_attachment_id_pt1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 5.1.4 on 2025-01-03 21:24

from sentry.new_migrations.migrations import CheckedMigration
from sentry.new_migrations.monkey.fields import SafeRemoveField
from sentry.new_migrations.monkey.state import DeletionAction


class Migration(CheckedMigration):
# This flag is used to mark that a migration shouldn't be automatically run in production.
# This should only be used for operations where it's safe to run the migration after your
# code has deployed. So this should not be used for most operations that alter the schema
# of a table.
# Here are some things that make sense to mark as post deployment:
# - Large data migrations. Typically we want these to be run manually so that they can be
# monitored and not block the deploy for a long period of time while they run.
# - Adding indexes to large tables. Since this can take a long time, we'd generally prefer to
# run this outside deployments so that we don't block them. Note that while adding an index
# is a schema change, it's completely safe to run the operation after the code has deployed.
# Once deployed, run these manually via: https://develop.sentry.dev/database-migrations/#migration-deployment

is_post_deployment = False

dependencies = [
("sentry", "0805_add_alert_and_member_invite_scopes_to_sentry_apps"),
]

operations = [
SafeRemoveField(
model_name="monitorcheckin",
name="attachment_id",
deletion_action=DeletionAction.MOVE_TO_PENDING,
)
]
14 changes: 1 addition & 13 deletions src/sentry/monitors/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from django.conf import settings
from django.db import models
from django.db.models import Case, IntegerField, Q, Value, When
from django.db.models.signals import post_delete, pre_save
from django.db.models.signals import pre_save
from django.dispatch import receiver
from django.utils import timezone

Expand Down Expand Up @@ -533,8 +533,6 @@ class MonitorCheckIn(Model):
that occurred during the check-in.
"""

attachment_id = BoundedBigIntegerField(null=True)

objects: ClassVar[BaseManager[Self]] = BaseManager(cache_fields=("guid",))

class Meta:
Expand Down Expand Up @@ -584,16 +582,6 @@ def _update_timestamps(self):
pass


def delete_file_for_monitorcheckin(instance: MonitorCheckIn, **kwargs):
if file_id := instance.attachment_id:
from sentry.models.files import File

File.objects.filter(id=file_id).delete()


post_delete.connect(delete_file_for_monitorcheckin, sender=MonitorCheckIn)


@region_silo_model
class MonitorLocation(Model):
__relocation_scope__ = RelocationScope.Excluded
Expand Down

This file was deleted.

0 comments on commit f6ce723

Please sign in to comment.