-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add timestamps to segments models (#4236)
- Loading branch information
Showing
2 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
84 changes: 84 additions & 0 deletions
84
api/segments/migrations/0024_add_timestamps_to_segments.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,84 @@ | ||
# Generated by Django 3.2.25 on 2024-06-25 19:46 | ||
|
||
from django.apps.registry import Apps | ||
from django.db import migrations, models | ||
from django.db.backends.base.schema import BaseDatabaseSchemaEditor | ||
|
||
|
||
def set_null_timestamps(apps: Apps, schema_editor: BaseDatabaseSchemaEditor) -> None: | ||
Segment = apps.get_model("segments", "Segment") | ||
Segment.objects.update(created_at=None, updated_at=None) | ||
HistoricalSegment = apps.get_model("segments", "HistoricalSegment") | ||
HistoricalSegment.objects.update(created_at=None, updated_at=None) | ||
Condition = apps.get_model("segments", "Condition") | ||
Condition.objects.update(created_at=None, updated_at=None) | ||
HistoricalCondition = apps.get_model("segments", "HistoricalCondition") | ||
HistoricalCondition.objects.update(created_at=None, updated_at=None) | ||
|
||
# Note that segment rules don't presently have a matching | ||
# HistoricalSegmentRule as the history is not set up. | ||
SegmentRule = apps.get_model("segments", "SegmentRule") | ||
SegmentRule.objects.update(created_at=None, updated_at=None) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("segments", "0023_add_versioning_to_segments"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="condition", | ||
name="created_at", | ||
field=models.DateTimeField(auto_now_add=True, null=True), | ||
), | ||
migrations.AddField( | ||
model_name="condition", | ||
name="updated_at", | ||
field=models.DateTimeField(auto_now=True, null=True), | ||
), | ||
migrations.AddField( | ||
model_name="historicalcondition", | ||
name="created_at", | ||
field=models.DateTimeField(blank=True, editable=False, null=True), | ||
), | ||
migrations.AddField( | ||
model_name="historicalcondition", | ||
name="updated_at", | ||
field=models.DateTimeField(blank=True, editable=False, null=True), | ||
), | ||
migrations.AddField( | ||
model_name="historicalsegment", | ||
name="created_at", | ||
field=models.DateTimeField(blank=True, editable=False, null=True), | ||
), | ||
migrations.AddField( | ||
model_name="historicalsegment", | ||
name="updated_at", | ||
field=models.DateTimeField(blank=True, editable=False, null=True), | ||
), | ||
migrations.AddField( | ||
model_name="segment", | ||
name="created_at", | ||
field=models.DateTimeField(auto_now_add=True, null=True), | ||
), | ||
migrations.AddField( | ||
model_name="segment", | ||
name="updated_at", | ||
field=models.DateTimeField(auto_now=True, null=True), | ||
), | ||
migrations.AddField( | ||
model_name="segmentrule", | ||
name="created_at", | ||
field=models.DateTimeField(auto_now_add=True, null=True), | ||
), | ||
migrations.AddField( | ||
model_name="segmentrule", | ||
name="updated_at", | ||
field=models.DateTimeField(auto_now=True, null=True), | ||
), | ||
migrations.RunPython( | ||
set_null_timestamps, reverse_code=migrations.RunPython.noop | ||
), | ||
] |
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