Skip to content

Commit

Permalink
ref: re-introduce migration to unpickle project options (#67436)
Browse files Browse the repository at this point in the history
copy paste of `0454_pickle_to_json_sentry_projectoptions` but
post-squash

<!-- Describe your PR here. -->
  • Loading branch information
asottile-sentry committed Mar 21, 2024
1 parent f1d2328 commit c987d30
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion migrations_lockfile.txt
Expand Up @@ -9,5 +9,5 @@ feedback: 0004_index_together
hybridcloud: 0015_apitokenreplica_hashed_token_index
nodestore: 0002_nodestore_no_dictfield
replays: 0004_index_together
sentry: 0676_apitoken_hashed_indexes
sentry: 0677_unpickle_project_options_again
social_auth: 0002_default_auto_field
34 changes: 34 additions & 0 deletions src/sentry/migrations/0677_unpickle_project_options_again.py
@@ -0,0 +1,34 @@
# Generated by Django 2.2.28 on 2023-05-19 17:25

from django.db import migrations

from sentry.new_migrations.migrations import CheckedMigration
from sentry.utils.query import RangeQuerySetWrapperWithProgressBar


def _backfill(apps, schema_editor):
cls = apps.get_model("sentry", "ProjectOption")

for obj in RangeQuerySetWrapperWithProgressBar(cls.objects.all()):
# load pickle, save json
obj.save(update_fields=["value"])


class Migration(CheckedMigration):
# data migration: must be run out of band
is_dangerous = True

# data migration: run outside of a transaction
atomic = False

dependencies = [
("sentry", "0676_apitoken_hashed_indexes"),
]

operations = [
migrations.RunPython(
_backfill,
migrations.RunPython.noop,
hints={"tables": ["sentry_projectoptions"]},
),
]

0 comments on commit c987d30

Please sign in to comment.