Browse Source

feat(semver): Add current_release_version to GroupResolution model (#27227)

Adds current_release_version field to GroupResolution model, which
represents the release version after which the issue will be resolved.
This is used for when we have semver releases and the `resolve in next release`
button in the UI is clicked
Ahmed Etefy 3 years ago
parent
commit
d0e3102393

+ 1 - 1
migrations_lockfile.txt

@@ -7,5 +7,5 @@ will then be regenerated, and you should be able to merge without conflicts.
 
 jira_ac: 0001_initial
 nodestore: 0002_nodestore_no_dictfield
-sentry: 0219_exporteddatablob_remove_blob_fk
+sentry: 0220_add_current_release_version_group_resolution
 social_auth: 0001_initial

+ 37 - 0
src/sentry/migrations/0220_add_current_release_version_group_resolution.py

@@ -0,0 +1,37 @@
+# Generated by Django 1.11.29 on 2021-07-08 08:32
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+    # This flag is used to mark that a migration shouldn't be automatically run in
+    # production. We set this to True for operations that we think are risky and want
+    # someone from ops to run manually and monitor.
+    # General advice is that if in doubt, mark your migration as `is_dangerous`.
+    # Some things you should always mark as dangerous:
+    # - Large data migrations. Typically we want these to be run manually by ops so that
+    #   they can be monitored. Since data migrations will now hold a transaction open
+    #   this is even more important.
+    # - Adding columns to highly active tables, even ones that are NULL.
+    is_dangerous = True
+
+    # This flag is used to decide whether to run this migration in a transaction or not.
+    # By default we prefer to run in a transaction, but for migrations where you want
+    # to `CREATE INDEX CONCURRENTLY` this needs to be set to False. Typically you'll
+    # want to create an index concurrently when adding one to an existing table.
+    # You'll also usually want to set this to `False` if you're writing a data
+    # migration, since we don't want the entire migration to run in one long-running
+    # transaction.
+    atomic = True
+
+    dependencies = [
+        ("sentry", "0219_exporteddatablob_remove_blob_fk"),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name="groupresolution",
+            name="current_release_version",
+            field=models.CharField(blank=True, max_length=250, null=True),
+        ),
+    ]

+ 6 - 0
src/sentry/models/groupresolution.py

@@ -3,6 +3,7 @@ from django.utils import timezone
 from django.utils.translation import ugettext_lazy as _
 
 from sentry.db.models import BoundedPositiveIntegerField, FlexibleForeignKey, Model, sane_repr
+from sentry.models.release import DB_VERSION_LENGTH
 
 
 class GroupResolution(Model):
@@ -24,6 +25,11 @@ class GroupResolution(Model):
     # the release in which its suggested this was resolved
     # which allows us to indicate if it still happens in newer versions
     release = FlexibleForeignKey("sentry.Release")
+    # This release field represents the release version of the bug when the user clicked on the
+    # "resolve in next release" button
+    # This column is specifically added for semver release comparison to be able to compare this
+    # semver release against "future/resolved" semver releases
+    current_release_version = models.CharField(max_length=DB_VERSION_LENGTH, null=True, blank=True)
     type = BoundedPositiveIntegerField(
         choices=((Type.in_next_release, "in_next_release"), (Type.in_release, "in_release")),
         null=True,