Skip to content

Commit 055056d

Browse files
ref: convert ProjectOption.value to django JSONField (#96682)
<!-- Describe your PR here. -->
1 parent e67a783 commit 055056d

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

migrations_lockfile.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ preprod: 0013_binary_uuid
2727

2828
replays: 0006_add_bulk_delete_job
2929

30-
sentry: 0959_add_has_logs_bit_to_project_model
30+
sentry: 0960_project_option_json_field
3131

3232
social_auth: 0003_social_auth_json_field
3333

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

src/sentry/models/options/project_option.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from sentry.backup.helpers import ImportFlags
1111
from sentry.backup.scopes import ImportScope, RelocationScope
1212
from sentry.db.models import FlexibleForeignKey, Model, region_silo_model, sane_repr
13-
from sentry.db.models.fields import PickledObjectField
1413
from sentry.db.models.manager.option import OptionManager
1514
from sentry.utils.cache import cache
1615

@@ -208,7 +207,7 @@ class ProjectOption(Model):
208207

209208
project = FlexibleForeignKey("sentry.Project")
210209
key = models.CharField(max_length=64)
211-
value = PickledObjectField(null=True)
210+
value = models.JSONField(null=True)
212211

213212
objects: ClassVar[ProjectOptionManager] = ProjectOptionManager()
214213

0 commit comments

Comments
 (0)