# Generated by Django 4.2.15 on 2024-09-06 03:58

from django.db import migrations
from api.models.release import Release


def migration_dryccfile(apps, schema_editor):
    for release in Release.objects.all():
        build = release.build
        if not build or not build.dryccfile or "pipeline" in build.dryccfile:
            continue
        pipeline = {}
        for key, value in build.dryccfile.get('deploy', {}).items():
            pipeline.update({
                "%s.yaml" % key: {
                    "kind": "pipeline",
                    "ptype": key,
                    "deploy": value,
                }
            })
        build.dryccfile = {"pipeline": pipeline}
        build.save()


class Migration(migrations.Migration):

    dependencies = [
        ('api', '0020_limitplan_runtime_class_name'),
    ]

    operations = [
        migrations.RunPython(migration_dryccfile),
    ]
