Просмотр исходного кода

ref: delete unused SentryFunction model (#70750)

already unused, this is the first step -- deleting it in state only

<!-- Describe your PR here. -->
anthony sottile 10 месяцев назад
Родитель
Сommit
667636e25f

+ 1 - 30
fixtures/backup/model_dependencies/detailed.json

@@ -5650,35 +5650,6 @@
       ]
     ]
   },
-  "sentry.sentryfunction": {
-    "dangling": false,
-    "foreign_keys": {
-      "organization": {
-        "kind": "FlexibleForeignKey",
-        "model": "sentry.organization",
-        "nullable": false
-      }
-    },
-    "model": "sentry.sentryfunction",
-    "relocation_dependencies": [],
-    "relocation_scope": "Excluded",
-    "silos": [
-      "Region"
-    ],
-    "table_name": "sentry_sentryfunction",
-    "uniques": [
-      [
-        "external_id"
-      ],
-      [
-        "organization",
-        "slug"
-      ],
-      [
-        "slug"
-      ]
-    ]
-  },
   "sentry.sentryshot": {
     "dangling": false,
     "foreign_keys": {
@@ -6177,4 +6148,4 @@
       ]
     ]
   }
-}
+}

+ 1 - 4
fixtures/backup/model_dependencies/flat.json

@@ -779,9 +779,6 @@
     "sentry.apitoken",
     "sentry.sentryappinstallation"
   ],
-  "sentry.sentryfunction": [
-    "sentry.organization"
-  ],
   "sentry.sentryshot": [
     "sentry.organization"
   ],
@@ -848,4 +845,4 @@
   "social_auth.usersocialauth": [
     "sentry.user"
   ]
-}
+}

+ 1 - 2
fixtures/backup/model_dependencies/sorted.json

@@ -46,7 +46,6 @@
   "sentry.repositoryprojectpathconfig",
   "sentry.reprocessingreport",
   "sentry.scheduleddeletion",
-  "sentry.sentryfunction",
   "sentry.sentryshot",
   "sentry.stringindexer",
   "sentry.team",
@@ -229,4 +228,4 @@
   "sentry.incidentseen",
   "sentry.incidentproject",
   "sentry.incidentactivity"
-]
+]

+ 1 - 2
fixtures/backup/model_dependencies/truncate.json

@@ -46,7 +46,6 @@
   "sentry_repositoryprojectpathconfig",
   "sentry_reprocessingreport",
   "sentry_scheduleddeletion",
-  "sentry_sentryfunction",
   "sentry_sentryshot",
   "sentry_stringindexer",
   "sentry_team",
@@ -229,4 +228,4 @@
   "sentry_incidentseen",
   "sentry_incidentproject",
   "sentry_incidentactivity"
-]
+]

+ 1 - 1
migrations_lockfile.txt

@@ -9,5 +9,5 @@ feedback: 0004_index_together
 hybridcloud: 0016_add_control_cacheversion
 nodestore: 0002_nodestore_no_dictfield
 replays: 0004_index_together
-sentry: 0720_remove_actor_columns
+sentry: 0721_delete_sentryfunctions
 social_auth: 0002_default_auto_field

+ 32 - 0
src/sentry/migrations/0721_delete_sentryfunctions.py

@@ -0,0 +1,32 @@
+# Generated by Django 5.0.4 on 2024-05-13 13:50
+
+from django.db import migrations
+
+from sentry.new_migrations.migrations import CheckedMigration
+
+
+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", "0720_remove_actor_columns"),
+    ]
+
+    operations = [
+        migrations.SeparateDatabaseAndState(
+            state_operations=[migrations.DeleteModel(name="SentryFunction")],
+            database_operations=[],
+        )
+    ]

+ 0 - 1
src/sentry/models/__init__.py

@@ -113,7 +113,6 @@ from .rulesnooze import RuleSnooze  # NOQA
 from .savedsearch import *  # NOQA
 from .scheduledeletion import *  # NOQA
 from .search_common import *  # NOQA
-from .sentryfunction import *  # NOQA
 from .sentryshot import *  # NOQA
 from .servicehook import *  # NOQA
 from .sourcemapprocessingissue import *  # NOQA

+ 0 - 38
src/sentry/models/sentryfunction.py

@@ -1,38 +0,0 @@
-from typing import ClassVar
-
-from django.db import models
-
-from sentry.backup.scopes import RelocationScope
-from sentry.db.models import BaseManager, DefaultFieldsModel, FlexibleForeignKey, region_silo_model
-from sentry.db.models.fields.array import ArrayField
-from sentry.db.models.fields.jsonfield import JSONField
-from sentry.db.models.fields.slug import SentrySlugField
-
-
-class SentryFunctionManager(BaseManager["SentryFunction"]):
-    def get_sentry_functions(self, organization_id, event_type):
-        functions = self.filter(organization_id=organization_id, events__contains=event_type)
-        return functions
-
-
-@region_silo_model
-class SentryFunction(DefaultFieldsModel):
-    """UNUSED! WILL BE DELETED!"""
-
-    __relocation_scope__ = RelocationScope.Excluded
-
-    organization = FlexibleForeignKey("sentry.Organization")
-    name = models.TextField()
-    slug = SentrySlugField(max_length=64, unique=True, db_index=False)
-    author = models.TextField()
-    external_id = models.CharField(max_length=128, unique=True)
-    overview = models.TextField(null=True)
-    code = models.TextField(null=True)
-    events = ArrayField(of=models.TextField, null=True)
-    env_variables = JSONField(default=dict)
-    objects: ClassVar[SentryFunctionManager] = SentryFunctionManager()
-
-    class Meta:
-        app_label = "sentry"
-        db_table = "sentry_sentryfunction"
-        unique_together = (("organization", "slug"),)

+ 0 - 5
tests/sentry/backup/snapshots/test_comparators/test_default_comparators.pysnap

@@ -1417,11 +1417,6 @@ source: tests/sentry/backup/test_comparators.py
     - api_token
     - sentry_app_installation
   model_name: sentry.sentryappinstallationtoken
-- comparators:
-  - class: ForeignKeyComparator
-    fields:
-    - organization
-  model_name: sentry.sentryfunction
 - comparators:
   - class: ForeignKeyComparator
     fields: