def forwards(self, orm):
from sentry.utils.query import RangeQuerySetWrapperWithProgressBar
Organization = orm['sentry.Organization']
Team = orm['sentry.Team']
queryset = Team.objects.filter(
organization__isnull=True,
)
user_orgs = {}
for team in RangeQuerySetWrapperWithProgressBar(queryset):
if team.owner_id not in user_orgs:
user_orgs[team.owner_id] = Organization.objects.create(
name=team.name.strip() or 'Default',
owner_id=team.owner_id,
)
team.organization = user_orgs[team.owner_id]
team.save()
transaction.commit()
评论列表
文章目录