Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrations(issue-views): Add projects, environemnts, time_filters, columns to GroupSearchView table #83284

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion migrations_lockfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ remote_subscriptions: 0003_drop_remote_subscription

replays: 0004_index_together

sentry: 0813_rm_alertruleactivation_models
sentry: 0814_create_groupsearchview_page_filter_columns

social_auth: 0002_default_auto_field

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Generated by Django 5.1.4 on 2025-01-14 16:51

from django.db import migrations, models

import sentry.db.models.fields.array
import sentry.models.groupsearchview
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", "0813_rm_alertruleactivation_models"),
]

operations = [
migrations.AddField(
model_name="groupsearchview",
name="environments",
field=sentry.db.models.fields.array.ArrayField(default=[], null=True),
),
migrations.AddField(
model_name="groupsearchview",
name="projects",
field=sentry.db.models.fields.array.ArrayField(default=[], null=True),
),
migrations.AddField(
model_name="groupsearchview",
name="time_filters",
field=models.JSONField(
default=sentry.models.groupsearchview.default_time_filters, null=True
),
),
]
17 changes: 17 additions & 0 deletions src/sentry/models/groupsearchview.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@
from django.db.models import UniqueConstraint

from sentry.backup.scopes import RelocationScope
from sentry.constants import ENVIRONMENT_NAME_MAX_LENGTH
from sentry.db.models import region_silo_model
from sentry.db.models.base import DefaultFieldsModelExisting
from sentry.db.models.fields.array import ArrayField
from sentry.db.models.fields.foreignkey import FlexibleForeignKey
from sentry.db.models.fields.hybrid_cloud_foreign_key import HybridCloudForeignKey
from sentry.models.savedsearch import SortOptions


def default_time_filters():
return {"period": "14d"}


@region_silo_model
class GroupSearchView(DefaultFieldsModelExisting):
"""
Expand All @@ -26,6 +32,17 @@ class GroupSearchView(DefaultFieldsModelExisting):
)
position = models.PositiveSmallIntegerField()

# projects = [] -> "My Projects"
# projects = [-1] -> "All Projects"
projects = ArrayField(models.IntegerField(), default=[], null=False)

# environments = [] -> "All Environments"
environments = ArrayField(
models.CharField(max_length=ENVIRONMENT_NAME_MAX_LENGTH), default=[], null=False
)

time_filters = models.JSONField(null=True, default=default_time_filters)

class Meta:
app_label = "sentry"
db_table = "sentry_groupsearchview"
Expand Down
Loading