Browse Source

ref(escalating-issues): Remove GroupForecast model (#47593)

Step 2 of removing the GroupForecast table

WOR-2966
Jodi Jang 1 year ago
parent
commit
c8788ff293

+ 1 - 1
migrations_lockfile.txt

@@ -6,5 +6,5 @@ To resolve this, rebase against latest master and regenerate your migration. Thi
 will then be regenerated, and you should be able to merge without conflicts.
 
 nodestore: 0002_nodestore_no_dictfield
-sentry: 0422_remove_group_forecast_fk_constraint
+sentry: 0423_remove_group_forecast_model
 social_auth: 0001_initial

+ 0 - 1
src/sentry/deletions/defaults/group.py

@@ -31,7 +31,6 @@ DIRECT_GROUP_RELATED_MODELS = (
     models.GroupSubscription,
     models.GroupHistory,
     models.RuleFireHistory,
-    models.GroupForecast,
 )
 
 _GROUP_RELATED_MODELS = DIRECT_GROUP_RELATED_MODELS + (

+ 30 - 0
src/sentry/migrations/0423_remove_group_forecast_model.py

@@ -0,0 +1,30 @@
+# Generated by Django 2.2.28 on 2023-04-18 21:12
+
+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. For
+    # the most part, 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 dangerous:
+    # - Large data migrations. Typically we want these to be run manually by ops 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
+    #   have ops run this and not block the deploy. Note that while adding an index is a schema
+    #   change, it's completely safe to run the operation after the code has deployed.
+    is_dangerous = False
+
+    dependencies = [
+        ("sentry", "0422_remove_group_forecast_fk_constraint"),
+    ]
+
+    operations = [
+        migrations.SeparateDatabaseAndState(
+            state_operations=[migrations.DeleteModel(name="GroupForecast")],
+            database_operations=[],
+        )
+    ]

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

@@ -42,7 +42,6 @@ from .groupbookmark import *  # NOQA
 from .groupcommitresolution import *  # NOQA
 from .groupemailthread import *  # NOQA
 from .groupenvironment import *  # NOQA
-from .groupforecast import *  # NOQA
 from .grouphash import *  # NOQA
 from .grouphistory import *  # NOQA
 from .groupinbox import *  # NOQA

+ 0 - 32
src/sentry/models/groupforecast.py

@@ -1,32 +0,0 @@
-from django.db import models
-from django.utils import timezone
-
-from sentry.db.models import (
-    ArrayField,
-    BoundedPositiveIntegerField,
-    FlexibleForeignKey,
-    Model,
-    region_silo_only_model,
-)
-
-
-@region_silo_only_model
-class GroupForecast(Model):
-    """
-    Stores the forecast of expected counts of events for a Group
-
-    ``forecast`` will hold an array of integers. The length of the array
-    is the difference between `date_created` and `valid_until`. Each integer
-    maps to the days in the range of `date_created` and `valid_until`.
-
-    """
-
-    __include_in_export__ = False
-
-    group = FlexibleForeignKey("sentry.Group", unique=True, db_constraint=False)
-    forecast = ArrayField(of=BoundedPositiveIntegerField, null=True)
-    date_added = models.DateTimeField(default=timezone.now)
-
-    class Meta:
-        app_label = "sentry"
-        db_table = "sentry_groupforecast"