mirror of https://github.com/sipwise/repoapi.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
842 B
32 lines
842 B
# Generated by Django 3.2.15 on 2022-12-16 15:12
|
|
import json
|
|
|
|
from django.conf import settings
|
|
from django.db import migrations
|
|
|
|
from buildinfo.utils import get_datetime
|
|
|
|
|
|
def restore_timestamps(apps, schema_editor):
|
|
BuildInfo = apps.get_model("buildinfo", "BuildInfo")
|
|
for info in BuildInfo.objects.all():
|
|
build_path = settings.JBI_BASEDIR.joinpath(
|
|
info.jobname, str(info.buildnumber), "build.json"
|
|
)
|
|
if build_path.exists():
|
|
with build_path.open("r") as f:
|
|
build_info = json.load(f)
|
|
info.datetime = get_datetime(build_info["timestamp"])
|
|
info.save()
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
("buildinfo", "0004_buildinfo_datetime"),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RunPython(restore_timestamps),
|
|
]
|