Skip to content

Commit f755d4c

Browse files
authored
fix(ACI): Filter migration and emit logs (#104053)
I ran this migration yesterday and it took 12 hours and was canceled. This updates it to only look for the ones where `type` is "email" and emits logs to keep track of progress. There are 1,799,316 rows with email as opposed to ~3m overall.
1 parent 2ec77e6 commit f755d4c

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/sentry/workflow_engine/migrations/0104_action_data_fallthrough_type.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,36 @@
11
# Generated by Django 5.2.8 on 2025-11-24 19:57
22

3+
import logging
4+
35
from django.db import migrations
46
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
57
from django.db.migrations.state import StateApps
68

79
from sentry.new_migrations.migrations import CheckedMigration
810
from sentry.utils.query import RangeQuerySetWrapper
911

12+
logger = logging.getLogger(__name__)
13+
1014

1115
def migrate_fallthrough_type(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:
1216
Action = apps.get_model("workflow_engine", "Action")
13-
for action in RangeQuerySetWrapper(Action.objects.all()):
17+
count = 0
18+
for action in RangeQuerySetWrapper(Action.objects.filter(type="email")):
1419
if "fallthroughType" in action.data:
1520
new_data = action.data.copy()
1621
del new_data["fallthroughType"]
1722
new_data["fallthrough_type"] = action.data["fallthroughType"]
1823
action.data = new_data
1924
action.save()
25+
count += 1
26+
if count % 1000 == 0:
27+
logger.info(
28+
"Progress update",
29+
extra={
30+
"count": count,
31+
"current_action_id": action.id,
32+
},
33+
)
2034

2135

2236
class Migration(CheckedMigration):

0 commit comments

Comments
 (0)