aboutsummaryrefslogtreecommitdiffstats
path: root/src/resource_inventory/migrations/0018_auto_20210630_1629.py
blob: 8062205e50cbd782d8fc08d6bfd95e7e90b39f72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# Generated by Django 2.2 on 2021-06-30 16:29

from django.db import migrations, models
import django.db.models.deletion
from account.models import *

#def set_architectures(apps, schema_editor):
#    model = apps.get_model('resource_inventory', 'Image')
#
#    #while model.objects.filter(architecture='
#    for obj in model.objects.all():
#        obj.architecture = 

def set_availability(apps, schema_editor):
    models = [apps.get_model('resource_inventory', 'Image'), apps.get_model('resource_inventory', 'Opsys')]

    for model in models:
        for obj in model.objects.all():
            obj.available = False
            obj.obsolete = True
            obj.save()

def set_rconfig_arch(apps, schema_editor):
    rprofs = apps.get_model('resource_inventory', 'ResourceProfile')

    for rprof in rprofs.objects.all():
        rprof.architecture = rprof.cpuprofile.first().architecture

class Migration(migrations.Migration):

    dependencies = [
        ('account', '0009_auto_20210324_2107'),
        ('resource_inventory', '0017_auto_20201218_1516'),
    ]

    operations = [
        migrations.RemoveField(
            model_name='image',
            name='host_type',
        ),
        migrations.AlterField(
            model_name='image',
            name='lab_id',
            field=models.CharField(default='none (retired)', max_length=100),
            preserve_default=True,
        ),
        migrations.RemoveField(
            model_name='opsys',
            name='sup_installers',
        ),

        migrations.AddField(
            model_name='image',
            name='architecture',
            field=models.CharField(choices=[('x86_64', 'x86_64'), ('aarch64', 'aarch64'), ('unknown', 'unknown')], default='unknown', max_length=50),
            preserve_default=False,
        ),

        migrations.AddField(
            model_name='image',
            name='available',
            field=models.BooleanField(default=True),
        ),
        migrations.AddField(
            model_name='image',
            name='obsolete',
            field=models.BooleanField(default=False),
        ),

        migrations.AddField(
            model_name='opsys',
            name='available',
            field=models.BooleanField(default=False),
        ),
        migrations.AddField(
            model_name='opsys',
            name='obsolete',
            field=models.BooleanField(default=True),
        ),

        migrations.RunPython(set_availability),

        migrations.AddField(
            model_name='opsys',
            name='lab_id',
            field=models.CharField(default="none (retired)", max_length=100),
            preserve_default=False,
        ),

        migrations.AddField(
            model_name='opsys',
            name='from_lab',
            field=models.ForeignKey(default=Lab.objects.first, on_delete=django.db.models.deletion.CASCADE, to='account.Lab'),
            preserve_default=False,
        ),

        migrations.AddField(
            model_name='resourceprofile',
            name='architecture',
            field=models.CharField(choices=[('x86_64', 'x86_64'), ('aarch64', 'aarch64'), ('unknown', 'unknown')], default='unknown', max_length=50),
            preserve_default=False,
        ),

        migrations.RunPython(set_rconfig_arch),
    ]