2022-04-26 13:30:11 +00:00
|
|
|
# Generated by Django 3.1.14 on 2022-04-26 07:58
|
|
|
|
|
|
|
|
from django.db import migrations
|
2022-09-23 02:15:07 +00:00
|
|
|
from assets.const import AllTypes
|
2022-04-28 04:47:39 +00:00
|
|
|
|
2022-04-26 13:30:11 +00:00
|
|
|
|
2022-09-23 02:15:07 +00:00
|
|
|
def create_internal_platforms(apps, *args):
|
|
|
|
AllTypes.create_or_update_internal_platforms()
|
2022-04-26 13:30:11 +00:00
|
|
|
|
2022-04-28 04:47:39 +00:00
|
|
|
|
2022-09-23 02:15:07 +00:00
|
|
|
def update_user_platforms(apps, *args):
|
|
|
|
platform_cls = apps.get_model('assets', 'Platform')
|
|
|
|
AllTypes.update_user_create_platforms(platform_cls)
|
2022-04-26 13:30:11 +00:00
|
|
|
|
|
|
|
|
2023-01-16 11:02:09 +00:00
|
|
|
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()
|
|
|
|
|
|
|
|
|
2022-04-26 13:30:11 +00:00
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
2022-08-24 08:14:32 +00:00
|
|
|
('assets', '0096_auto_20220426_1550'),
|
2022-04-26 13:30:11 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
operations = [
|
2022-09-23 02:15:07 +00:00
|
|
|
migrations.RunPython(create_internal_platforms),
|
|
|
|
migrations.RunPython(update_user_platforms),
|
2023-01-16 11:02:09 +00:00
|
|
|
migrations.RunPython(migrate_macos_platform),
|
2022-04-26 13:30:11 +00:00
|
|
|
]
|