2022-12-15 07:21:51 +00:00
|
|
|
# Generated by Django 3.2.14 on 2022-12-15 07:08
|
|
|
|
|
|
|
|
from django.db import migrations
|
|
|
|
|
|
|
|
|
|
|
|
def migrate_del_macos(apps, schema_editor):
|
|
|
|
db_alias = schema_editor.connection.alias
|
|
|
|
asset_model = apps.get_model('assets', 'Asset')
|
|
|
|
platform_model = apps.get_model('assets', 'Platform')
|
2022-12-16 07:53:59 +00:00
|
|
|
old_macos = platform_model.objects.using(db_alias).filter(
|
2022-12-15 07:21:51 +00:00
|
|
|
name='MacOS', type='macos'
|
2022-12-16 07:53:59 +00:00
|
|
|
).first()
|
|
|
|
new_macos = platform_model.objects.using(db_alias).filter(
|
2022-12-15 07:21:51 +00:00
|
|
|
name='macOS', type='unix'
|
2022-12-16 07:53:59 +00:00
|
|
|
).first()
|
|
|
|
|
|
|
|
if not old_macos or not new_macos:
|
|
|
|
return
|
|
|
|
|
2022-12-15 07:21:51 +00:00
|
|
|
asset_model.objects.using(db_alias).filter(
|
2022-12-16 07:53:59 +00:00
|
|
|
platform=old_macos
|
|
|
|
).update(platform=new_macos)
|
2022-12-15 07:21:51 +00:00
|
|
|
|
|
|
|
platform_model.objects.using(db_alias).filter(id=old_macos.id).delete()
|
|
|
|
|
|
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
|
|
('assets', '0113_auto_20221122_2015'),
|
|
|
|
]
|
|
|
|
|
|
|
|
operations = [
|
|
|
|
migrations.RunPython(migrate_del_macos),
|
|
|
|
]
|