User migration
* fixes bug in user migration * catches error in compensation migration on KOM of corrupted EIVs * optimized log migration
This commit is contained in:
parent
492110882b
commit
9d11008fee
@ -145,7 +145,6 @@ class BaseMigrater:
|
||||
fetch_results = tmp_cursor.fetchall()
|
||||
|
||||
migrated_identifier = "(migriert)"
|
||||
instance.log.filter(comment__contains=migrated_identifier).delete()
|
||||
for result in fetch_results:
|
||||
comment = f"{result[0]} {migrated_identifier}"
|
||||
timestamp = make_aware(result[1])
|
||||
@ -169,15 +168,15 @@ class BaseMigrater:
|
||||
action.save()
|
||||
action.timestamp = timestamp
|
||||
action.save()
|
||||
instance.log.add(action)
|
||||
instance.log.add(action)
|
||||
|
||||
first_entry = instance.log.order_by("timestamp").first()
|
||||
last_entry = instance.log.order_by("-timestamp").first()
|
||||
|
||||
if first_entry is not None and instance.created is None:
|
||||
instance.created = UserActionLogEntry.get_created_action(first_entry.user)
|
||||
instance.created.timestamp = first_entry.timestamp
|
||||
instance.created.save()
|
||||
first_entry.action = UserAction.CREATED
|
||||
first_entry.save()
|
||||
instance.created = first_entry
|
||||
if last_entry is not None and instance.modified != last_entry:
|
||||
instance.modified = last_entry
|
||||
|
||||
|
@ -99,7 +99,7 @@ class CompensationMigrater(BaseMigrater):
|
||||
eivs = tmp_cursor.fetchall()
|
||||
len_eivs = len(eivs)
|
||||
if len_eivs != 1:
|
||||
raise AssertionError(f"{kom_identifier} has {len_eivs} EIVs!")
|
||||
raise ObjectDoesNotExist(f"{kom_identifier} has {len_eivs} EIVs!")
|
||||
eiv = eivs[0]
|
||||
try:
|
||||
intervention = Intervention.objects.get(
|
||||
|
@ -39,9 +39,10 @@ class UserMigrater(BaseMigrater):
|
||||
user = User.objects.get_or_create(
|
||||
username=result[0]
|
||||
)[0]
|
||||
user.last_name = result[2]
|
||||
user.last_name = result[1]
|
||||
user.first_name = result[2]
|
||||
user.email = result[3]
|
||||
user.save()
|
||||
|
||||
appusers = result[4].split(";;;")
|
||||
user_teams = []
|
||||
|
Loading…
Reference in New Issue
Block a user