mirror of https://github.com/jumpserver/jumpserver
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.7 KiB
55 lines
1.7 KiB
# Generated by Django 3.1.14 on 2022-04-26 07:58
|
|
|
|
from django.db import migrations
|
|
from assets.const import AllTypes
|
|
|
|
|
|
def create_internal_platforms(apps, *args):
|
|
AllTypes.create_or_update_internal_platforms()
|
|
|
|
|
|
def update_user_platforms(apps, *args):
|
|
platform_cls = apps.get_model('assets', 'Platform')
|
|
AllTypes.update_user_create_platforms(platform_cls)
|
|
|
|
|
|
def migrate_macos_platform(apps, schema_editor):
|
|
db_alias = schema_editor.connection.alias
|
|
asset_model = apps.get_model('assets', 'Asset')
|
|
platform_model = apps.get_model('assets', 'Platform')
|
|
old_macos = platform_model.objects.using(db_alias).filter(
|
|
name='MacOS', type='macos'
|
|
).first()
|
|
new_macos = platform_model.objects.using(db_alias).filter(
|
|
name='macOS', type='unix'
|
|
).first()
|
|
|
|
if not old_macos or not new_macos:
|
|
return
|
|
|
|
asset_model.objects.using(db_alias).filter(
|
|
platform=old_macos
|
|
).update(platform=new_macos)
|
|
|
|
platform_model.objects.using(db_alias).filter(id=old_macos.id).delete()
|
|
|
|
|
|
def migrate_connectivity(apps, schema_editor):
|
|
db_alias = schema_editor.connection.alias
|
|
asset_model = apps.get_model('assets', 'Asset')
|
|
asset_model.objects.using(db_alias).filter(connectivity='unknown').update(connectivity='-')
|
|
asset_model.objects.using(db_alias).filter(connectivity='failed').update(connectivity='err')
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
dependencies = [
|
|
('assets', '0096_auto_20220426_1550'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RunPython(create_internal_platforms),
|
|
migrations.RunPython(update_user_platforms),
|
|
migrations.RunPython(migrate_macos_platform),
|
|
migrations.RunPython(migrate_connectivity),
|
|
]
|