forked from rapidpro/rapidpro
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrations to add CampaignEvent.fire_uuid correctly
- Loading branch information
1 parent
834aa73
commit 46a78a4
Showing
4 changed files
with
54 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
temba/campaigns/migrations/0068_backfill_event_fire_uuid.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Generated by Django 5.1.4 on 2025-02-28 20:53 | ||
|
||
from django.db import migrations | ||
|
||
from temba.utils.uuid import uuid4 | ||
|
||
|
||
def backfill_event_fire_uuid(apps, schema_editor): # pragma: no cover | ||
CampaignEvent = apps.get_model("campaigns", "CampaignEvent") | ||
|
||
for event in CampaignEvent.objects.filter(fire_uuid=None).only("id"): | ||
event.fire_uuid = uuid4() | ||
event.save(update_fields=("fire_uuid",)) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("campaigns", "0067_campaignevent_fire_uuid_campaignevent_status"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(backfill_event_fire_uuid, migrations.RunPython.noop), | ||
] |
20 changes: 20 additions & 0 deletions
20
temba/campaigns/migrations/0069_alter_campaignevent_fire_uuid.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Generated by Django 5.1.4 on 2025-02-28 20:55 | ||
|
||
from django.db import migrations, models | ||
|
||
import temba.utils.uuid | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("campaigns", "0068_backfill_event_fire_uuid"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="campaignevent", | ||
name="fire_uuid", | ||
field=models.UUIDField(default=temba.utils.uuid.uuid4), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters