-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(segments): add migration to set version on existing segments (#4315)
- Loading branch information
1 parent
8e9659e
commit 288a47e
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
api/segments/migrations/0025_set_default_version_on_segment.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,23 @@ | ||
# Generated by Django 3.2.25 on 2024-07-09 10:41 | ||
from django.apps.registry import Apps | ||
from django.db import migrations | ||
from django.db.backends.base.schema import BaseDatabaseSchemaEditor | ||
|
||
|
||
def set_default_segment_version( | ||
apps: Apps, | ||
schema_editor: BaseDatabaseSchemaEditor, | ||
) -> None: | ||
segment_model_class = apps.get_model("segments", "Segment") | ||
segment_model_class.objects.filter(version__isnull=True).update(version=1) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('segments', '0024_add_timestamps_to_segments'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(set_default_segment_version, reverse_code=migrations.RunPython.noop), | ||
] |