0001-environment-clean-old-auto-variable-for-internal-ips.patch
hobo/environment/migrations/0028_clean_internal_ips.py | ||
---|---|---|
1 |
# Generated by Django 2.2.28 on 2022-07-01 07:11 |
|
2 | ||
3 |
from django.db import migrations |
|
4 | ||
5 | ||
6 |
def clean_internal_ips(apps, schema_editor): |
|
7 |
Variable = apps.get_model('environment', 'Variable') |
|
8 |
for var in Variable.objects.filter(name='SETTING_INTERNAL_IPS', service_pk__isnull=True, auto=True): |
|
9 |
if Variable.objects.filter( |
|
10 |
name='SETTING_INTERNAL_IPS.extend', service_pk__isnull=True, auto=True |
|
11 |
).exists(): |
|
12 |
var.delete() |
|
13 |
else: |
|
14 |
var.name = 'SETTING_INTERNAL_IPS.extend' |
|
15 |
var.save() |
|
16 | ||
17 | ||
18 |
class Migration(migrations.Migration): |
|
19 | ||
20 |
dependencies = [ |
|
21 |
('environment', '0027_allow_long_slug'), |
|
22 |
] |
|
23 | ||
24 |
operations = [ |
|
25 |
migrations.RunPython(clean_internal_ips, migrations.RunPython.noop), |
|
26 |
] |
|
0 |
- |