diff --git a/apps/assets/migrations/0098_auto_20220430_2126.py b/apps/assets/migrations/0098_auto_20220430_2126.py index 89a168316..5fd333262 100644 --- a/apps/assets/migrations/0098_auto_20220430_2126.py +++ b/apps/assets/migrations/0098_auto_20220430_2126.py @@ -34,8 +34,9 @@ def migrate_database_to_asset(apps, *args): _attrs = app.attrs or {} attrs.update(_attrs) + name = 'DB-{}'.format(app.name) db = db_model( - id=app.id, name=app.name, address=attrs['host'], + id=app.id, name=name, address=attrs['host'], protocols='{}/{}'.format(app.type, attrs['port']), db_name=attrs['database'] or '', platform=platforms_map[app.type], @@ -61,8 +62,9 @@ def migrate_cloud_to_asset(apps, *args): for app in applications: attrs = app.attrs print("\t- Create cloud: {}".format(app.name)) + name = 'Cloud-{}'.format(app.name) cloud = cloud_model( - id=app.id, name=app.name, + id=app.id, name=name, address=attrs.get('cluster', ''), protocols='k8s/443', platform=platform, org_id=app.org_id, diff --git a/apps/perms/migrations/0029_auto_20220728_1728.py b/apps/perms/migrations/0029_auto_20220728_1728.py index fce1f43a4..0230e9aff 100644 --- a/apps/perms/migrations/0029_auto_20220728_1728.py +++ b/apps/perms/migrations/0029_auto_20220728_1728.py @@ -23,6 +23,7 @@ def migrate_app_perms_to_assets(apps, schema_editor): asset_permission = asset_permission_model() for attr in attrs: setattr(asset_permission, attr, getattr(app_perm, attr)) + asset_permission.name = f"App-{app_perm.name}" asset_permissions.append(asset_permission) asset_permission_model.objects.bulk_create(asset_permissions, ignore_conflicts=True) diff --git a/apps/perms/migrations/0030_auto_20220816_1132.py b/apps/perms/migrations/0030_auto_20220816_1132.py index d6b2710fc..3915b8b1a 100644 --- a/apps/perms/migrations/0030_auto_20220816_1132.py +++ b/apps/perms/migrations/0030_auto_20220816_1132.py @@ -9,11 +9,11 @@ def migrate_system_user_to_accounts(apps, schema_editor): bulk_size = 10000 while True: asset_permissions = asset_permission_model.objects \ - .prefetch_related('system_users')[count:bulk_size] + .prefetch_related('system_users')[count:bulk_size] if not asset_permissions: break - count += len(asset_permissions) + count += len(asset_permissions) updated = [] for asset_permission in asset_permissions: asset_permission.accounts = [s.username for s in asset_permission.system_users.all()]