Skip to content

Commit

Permalink
fix(segments): add migration to set version on existing segments (#4315)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewelwell authored Jul 9, 2024
1 parent 8e9659e commit 288a47e
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions api/segments/migrations/0025_set_default_version_on_segment.py
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),
]

0 comments on commit 288a47e

Please sign in to comment.