Skip to content

Commit 0d5a55d

Browse files
ref: convert sentry_apps array fields to django ArrayField (#92065)
<!-- Describe your PR here. -->
1 parent cdcc87e commit 0d5a55d

File tree

4 files changed

+48
-5
lines changed

4 files changed

+48
-5
lines changed

migrations_lockfile.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ nodestore: 0001_squashed_0002_nodestore_no_dictfield
2121

2222
replays: 0001_squashed_0005_drop_replay_index
2323

24-
sentry: 0906_django_arrayfield_users
24+
sentry: 0907_sentry_apps_array
2525

2626
social_auth: 0001_squashed_0002_default_auto_field
2727

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Generated by Django 5.2.1 on 2025-05-21 20:57
2+
3+
import django.contrib.postgres.fields
4+
from django.db import migrations, models
5+
6+
from sentry.new_migrations.migrations import CheckedMigration
7+
8+
9+
class Migration(CheckedMigration):
10+
# This flag is used to mark that a migration shouldn't be automatically run in production.
11+
# This should only be used for operations where it's safe to run the migration after your
12+
# code has deployed. So this should not be used for most operations that alter the schema
13+
# of a table.
14+
# Here are some things that make sense to mark as post deployment:
15+
# - Large data migrations. Typically we want these to be run manually so that they can be
16+
# monitored and not block the deploy for a long period of time while they run.
17+
# - Adding indexes to large tables. Since this can take a long time, we'd generally prefer to
18+
# run this outside deployments so that we don't block them. Note that while adding an index
19+
# is a schema change, it's completely safe to run the operation after the code has deployed.
20+
# Once deployed, run these manually via: https://develop.sentry.dev/database-migrations/#migration-deployment
21+
22+
is_post_deployment = True
23+
24+
dependencies = [
25+
("sentry", "0906_django_arrayfield_users"),
26+
]
27+
28+
operations = [
29+
migrations.AlterField(
30+
model_name="sentryapp",
31+
name="events",
32+
field=django.contrib.postgres.fields.ArrayField(
33+
base_field=models.TextField(), default=list, size=None
34+
),
35+
),
36+
migrations.AlterField(
37+
model_name="servicehook",
38+
name="events",
39+
field=django.contrib.postgres.fields.ArrayField(
40+
base_field=models.TextField(), default=list, size=None
41+
),
42+
),
43+
]

src/sentry/sentry_apps/models/sentry_app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from hashlib import sha256
55
from typing import Any, ClassVar
66

7+
from django.contrib.postgres.fields.array import ArrayField
78
from django.db import models, router, transaction
89
from django.db.models import QuerySet
910
from django.utils import timezone
@@ -18,7 +19,6 @@
1819
SentryAppStatus,
1920
)
2021
from sentry.db.models import (
21-
ArrayField,
2222
BoundedPositiveIntegerField,
2323
FlexibleForeignKey,
2424
Model,
@@ -141,7 +141,7 @@ class SentryApp(ParanoidModel, HasApiScopes, Model):
141141
# are successfully installed ?
142142
verify_install = models.BooleanField(default=True)
143143

144-
events = ArrayField(of=models.TextField, null=True)
144+
events = ArrayField(models.TextField(), default=list)
145145

146146
overview = models.TextField(null=True)
147147
schema = JSONField(default=dict)

src/sentry/sentry_apps/models/servicehook.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from typing import Any, ClassVar, Self
66
from uuid import uuid4
77

8+
from django.contrib.postgres.fields.array import ArrayField
89
from django.db import models
910
from django.utils import timezone
1011

@@ -13,7 +14,6 @@
1314
from sentry.backup.scopes import RelocationScope
1415
from sentry.constants import ObjectStatus
1516
from sentry.db.models import (
16-
ArrayField,
1717
BoundedPositiveIntegerField,
1818
FlexibleForeignKey,
1919
Model,
@@ -68,7 +68,7 @@ class ServiceHook(Model):
6868
organization_id = BoundedBigIntegerField(db_index=True, null=True)
6969
url = models.URLField(max_length=512)
7070
secret = models.TextField(default=generate_secret)
71-
events = ArrayField(of=models.TextField)
71+
events = ArrayField(models.TextField(), default=list)
7272
status = BoundedPositiveIntegerField(
7373
default=0, choices=ObjectStatus.as_choices(), db_index=True
7474
)

0 commit comments

Comments
 (0)