perf: 修改 connectivity

pull/9380/head
ibuler 2 years ago
parent 03c0d2edbd
commit 6bbb1f7e86

@ -13,7 +13,7 @@ class Migration(migrations.Migration):
migrations.AddField( migrations.AddField(
model_name='asset', model_name='asset',
name='connectivity', name='connectivity',
field=models.CharField(choices=[('unknown', 'Unknown'), ('ok', 'Ok'), ('failed', 'Failed')], default='unknown', max_length=16, verbose_name='Connectivity'), field=models.CharField(choices=[('-', 'Unknown'), ('ok', 'Ok'), ('err', 'Error')], default='-', max_length=16, verbose_name='Connectivity'),
), ),
migrations.AddField( migrations.AddField(
model_name='asset', model_name='asset',
@ -23,7 +23,7 @@ class Migration(migrations.Migration):
migrations.AddField( migrations.AddField(
model_name='authbook', model_name='authbook',
name='connectivity', name='connectivity',
field=models.CharField(choices=[('unknown', 'Unknown'), ('ok', 'Ok'), ('failed', 'Failed')], default='unknown', max_length=16, verbose_name='Connectivity'), field=models.CharField(choices=[('-', 'Unknown'), ('ok', 'Ok'), ('err', 'Error')], default='-', max_length=16, verbose_name='Connectivity'),
), ),
migrations.AddField( migrations.AddField(
model_name='authbook', model_name='authbook',
@ -33,7 +33,7 @@ class Migration(migrations.Migration):
migrations.AddField( migrations.AddField(
model_name='historicalauthbook', model_name='historicalauthbook',
name='connectivity', name='connectivity',
field=models.CharField(choices=[('unknown', 'Unknown'), ('ok', 'Ok'), ('failed', 'Failed')], default='unknown', max_length=16, verbose_name='Connectivity'), field=models.CharField(choices=[('-', 'Unknown'), ('ok', 'Ok'), ('err', 'Error')], default='-', max_length=16, verbose_name='Connectivity'),
), ),
migrations.AddField( migrations.AddField(
model_name='historicalauthbook', model_name='historicalauthbook',

@ -34,6 +34,13 @@ def migrate_macos_platform(apps, schema_editor):
platform_model.objects.using(db_alias).filter(id=old_macos.id).delete() 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): class Migration(migrations.Migration):
dependencies = [ dependencies = [
('assets', '0096_auto_20220426_1550'), ('assets', '0096_auto_20220426_1550'),
@ -43,4 +50,5 @@ class Migration(migrations.Migration):
migrations.RunPython(create_internal_platforms), migrations.RunPython(create_internal_platforms),
migrations.RunPython(update_user_platforms), migrations.RunPython(update_user_platforms),
migrations.RunPython(migrate_macos_platform), migrations.RunPython(migrate_macos_platform),
migrations.RunPython(migrate_connectivity),
] ]

Loading…
Cancel
Save