mirror of https://github.com/jumpserver/jumpserver
50 lines
1.5 KiB
Python
50 lines
1.5 KiB
Python
# Generated by Django 3.2.17 on 2023-03-21 08:33
|
|
|
|
from django.db import migrations, models
|
|
|
|
from assets.const import AllTypes
|
|
|
|
|
|
def migrate_platform_charset(apps, schema_editor):
|
|
platform_model = apps.get_model('assets', 'Platform')
|
|
platform_model.objects.filter(charset='utf8').update(charset='utf-8')
|
|
|
|
|
|
def migrate_platform_protocol_primary(apps, schema_editor):
|
|
platform_model = apps.get_model('assets', 'Platform')
|
|
platforms = platform_model.objects.all()
|
|
|
|
for platform in platforms:
|
|
p = platform.protocols.first()
|
|
if not p:
|
|
continue
|
|
p.primary = True
|
|
p.save()
|
|
|
|
|
|
def migrate_internal_platforms(apps, schema_editor):
|
|
platform_cls = apps.get_model('assets', 'Platform')
|
|
AllTypes.create_or_update_internal_platforms(platform_cls)
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
dependencies = [
|
|
('assets', '0110_auto_20230315_1741'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.AddField(
|
|
model_name='platformprotocol',
|
|
name='primary',
|
|
field=models.BooleanField(default=False, verbose_name='Primary'),
|
|
),
|
|
migrations.AddField(
|
|
model_name='platformprotocol',
|
|
name='public',
|
|
field=models.BooleanField(default=True, verbose_name='Public'),
|
|
),
|
|
migrations.RunPython(migrate_platform_charset),
|
|
migrations.RunPython(migrate_platform_protocol_primary),
|
|
migrations.RunPython(migrate_internal_platforms),
|
|
]
|