diff --git a/migrations_lockfile.txt b/migrations_lockfile.txt index ef5dca6dfbdf2f..76fcd9dde16538 100644 --- a/migrations_lockfile.txt +++ b/migrations_lockfile.txt @@ -15,7 +15,7 @@ remote_subscriptions: 0003_drop_remote_subscription replays: 0004_index_together -sentry: 0838_backfill_groupsearchview_positions_to_gsvstarred +sentry: 0839_add_visibility_column_to_groupsearchview social_auth: 0002_default_auto_field diff --git a/src/sentry/migrations/0839_add_visibility_column_to_groupsearchview.py b/src/sentry/migrations/0839_add_visibility_column_to_groupsearchview.py new file mode 100644 index 00000000000000..21d2e40fd12d9d --- /dev/null +++ b/src/sentry/migrations/0839_add_visibility_column_to_groupsearchview.py @@ -0,0 +1,33 @@ +# Generated by Django 5.1.5 on 2025-03-05 23:35 + +from django.db import migrations, models + +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", "0838_backfill_groupsearchview_positions_to_gsvstarred"), + ] + + operations = [ + migrations.AddField( + model_name="groupsearchview", + name="visibility", + field=models.CharField(db_default="owner", max_length=16), + ), + ] diff --git a/src/sentry/models/groupsearchview.py b/src/sentry/models/groupsearchview.py index ed03f8b4de0329..ca942828884c3a 100644 --- a/src/sentry/models/groupsearchview.py +++ b/src/sentry/models/groupsearchview.py @@ -1,5 +1,8 @@ +from typing import Any + from django.db import models from django.db.models import UniqueConstraint +from django.utils.translation import gettext_lazy as _ from sentry.backup.scopes import RelocationScope from sentry.constants import ENVIRONMENT_NAME_MAX_LENGTH @@ -26,6 +29,18 @@ class Meta: unique_together = (("group_search_view", "project"),) +class GroupSearchViewVisibility: + ORGANIZATION = "organization" + OWNER = "owner" + + @classmethod + def as_choices(cls) -> list[tuple[str, Any]]: + return [ + (cls.ORGANIZATION, _("Organization")), + (cls.OWNER, _("Only for me")), + ] + + @region_silo_model class GroupSearchView(DefaultFieldsModelExisting): """ @@ -37,6 +52,12 @@ class GroupSearchView(DefaultFieldsModelExisting): user_id = HybridCloudForeignKey("sentry.User", on_delete="CASCADE") organization = FlexibleForeignKey("sentry.Organization") + visibility = models.CharField( + max_length=16, + db_default=GroupSearchViewVisibility.OWNER, + choices=GroupSearchViewVisibility.as_choices(), + ) + query = models.TextField() query_sort = models.CharField( max_length=16, default=SortOptions.DATE, choices=SortOptions.as_choices()