mirror of https://github.com/jumpserver/jumpserver
fix: 修复迁移数据库应用账号缺少的问题
parent
8be25e1944
commit
cf2089d826
|
@ -81,7 +81,7 @@ def migrate_db_accounts(apps, schema_editor):
|
|||
perms = app_perm_model.objects.filter(category__in=['db', 'cloud'])
|
||||
|
||||
same_attrs = [
|
||||
'id', 'username', 'comment', 'date_created', 'date_updated',
|
||||
'username', 'comment', 'date_created', 'date_updated',
|
||||
'created_by', 'org_id',
|
||||
]
|
||||
auth_attrs = ['password', 'private_key', 'token']
|
||||
|
@ -96,6 +96,7 @@ def migrate_db_accounts(apps, schema_editor):
|
|||
index += 1
|
||||
start = time.time()
|
||||
|
||||
apps = perm.applications.all()
|
||||
system_users = perm.system_users.all()
|
||||
accounts = []
|
||||
for s in system_users:
|
||||
|
@ -125,13 +126,14 @@ def migrate_db_accounts(apps, schema_editor):
|
|||
auth_infos.append((username, 'password', ''))
|
||||
|
||||
for name, secret_type, secret in auth_infos:
|
||||
account = account_model(**values, name=name, secret=secret, secret_type=secret_type)
|
||||
accounts.append(account)
|
||||
values['name'] = name
|
||||
values['secret_type'] = secret_type
|
||||
values['secret'] = secret
|
||||
|
||||
apps = perm.applications.all()
|
||||
for app in apps:
|
||||
for account in accounts:
|
||||
setattr(account, 'asset_id', str(app.id))
|
||||
for app in apps:
|
||||
values['asset_id'] = str(app.id)
|
||||
account = account_model(**values)
|
||||
accounts.append(account)
|
||||
|
||||
account_model.objects.bulk_create(accounts, ignore_conflicts=True)
|
||||
|
||||
|
|
Loading…
Reference in New Issue