# Generated by Django 3.2.16 on 2023-02-06 11:27 from django.db import migrations, models def compatible(apps, schema_editor): """ 兼容旧版本的数据 """ model = apps.get_model("ops", "JobExecution") for obj in model.objects.all(): if obj.job: if obj.job.type == 'adhoc': obj.material = "{}:{}".format(obj.job.module, obj.job.args) if obj.job.type == 'playbook': obj.material = "{}:{}:{}".format(obj.job.org.name, obj.job.creator.name, obj.job.playbook.name) obj.job_type = obj.job.type obj.save() else: obj.delete() class Migration(migrations.Migration): dependencies = [ ('ops', '0026_alter_jobexecution_job'), ] operations = [ migrations.AddField( model_name='jobexecution', name='job_type', field=models.CharField(choices=[('adhoc', 'Adhoc'), ('playbook', 'Playbook')], default='adhoc', max_length=128, verbose_name='Material Type'), ), migrations.AddField( model_name='jobexecution', name='material', field=models.CharField(blank=True, default='', max_length=1024, null=True, verbose_name='Material'), ), migrations.RunPython(compatible), ]