Skip to content

Commit

Permalink
Revert "fix(migrations) Conditionally remove groupsubscription columns (
Browse files Browse the repository at this point in the history
#55870)"

This reverts commit 761041e.

Co-authored-by: mattgauntseo-sentry <112419115+mattgauntseo-sentry@users.noreply.github.com>
  • Loading branch information
getsentry-bot and mattgauntseo-sentry committed Sep 7, 2023
1 parent f10ffe4 commit 03285f6
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 64 deletions.
6 changes: 5 additions & 1 deletion fixtures/backup/model_dependencies/detailed.json
Original file line number Diff line number Diff line change
Expand Up @@ -1471,6 +1471,10 @@
"kind": "FlexibleForeignKey",
"model": "sentry.Project"
},
"team": {
"kind": "FlexibleForeignKey",
"model": "sentry.Team"
},
"user_id": {
"kind": "HybridCloudForeignKey",
"model": "sentry.User"
Expand Down Expand Up @@ -3389,4 +3393,4 @@
"Control"
]
}
}
}
3 changes: 2 additions & 1 deletion fixtures/backup/model_dependencies/flat.json
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@
"sentry.GroupSubscription": [
"sentry.Group",
"sentry.Project",
"sentry.Team",
"sentry.User"
],
"sentry.GroupTombstone": [
Expand Down Expand Up @@ -765,4 +766,4 @@
"social_auth.UserSocialAuth": [
"sentry.User"
]
}
}
2 changes: 1 addition & 1 deletion migrations_lockfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ will then be regenerated, and you should be able to merge without conflicts.
feedback: 0001_feedback
nodestore: 0002_nodestore_no_dictfield
replays: 0003_add_size_to_recording_segment
sentry: 0545_remove_groupsubscription_columns
sentry: 0544_add_commitfilechange_language_col
social_auth: 0002_default_auto_field
57 changes: 0 additions & 57 deletions src/sentry/migrations/0545_remove_groupsubscription_columns.py

This file was deleted.

10 changes: 9 additions & 1 deletion src/sentry/models/groupsubscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ class GroupSubscription(Model):
project = FlexibleForeignKey("sentry.Project", related_name="subscription_set")
group = FlexibleForeignKey("sentry.Group", related_name="subscription_set")
user_id = HybridCloudForeignKey(settings.AUTH_USER_MODEL, null=True, on_delete="CASCADE")
team = FlexibleForeignKey("sentry.Team", null=True, db_index=True, on_delete=models.CASCADE)
is_active = models.BooleanField(default=True)
reason = BoundedPositiveIntegerField(default=GroupSubscriptionReason.unknown)
date_added = models.DateTimeField(default=timezone.now, null=True)
Expand All @@ -188,6 +189,13 @@ class GroupSubscription(Model):
class Meta:
app_label = "sentry"
db_table = "sentry_groupsubscription"
unique_together = (("group", "user_id"),)
unique_together = (("group", "user_id"), ("group", "team"))
constraints = [
models.CheckConstraint(
check=models.Q(team_id__isnull=False, user_id__isnull=True)
| models.Q(team_id__isnull=True, user_id__isnull=False),
name="subscription_team_or_user_check",
)
]

__repr__ = sane_repr("project_id", "group_id", "user_id")
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import pytest

from sentry.models import SavedSearch, SearchType
from sentry.testutils.cases import TestMigrations


@pytest.mark.skip("Migration 0545 results in this failing even with reverse operations.")
class BackfillSaveSearchAssignedQueryTest(TestMigrations):
migrate_from = "0501_typed_bitfield_remove_labels"
migrate_to = "0502_savedsearch_update_me_myteams"
Expand Down

0 comments on commit 03285f6

Please sign in to comment.