We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f42c480 commit 9f66cb9Copy full SHA for 9f66cb9
1 file changed
scripts/migrate_v0x_to_v1.py
@@ -67,12 +67,18 @@ def migrate_org_data():
67
68
updated = 0
69
for row in data_records:
70
- orgs = row.user.organization.all()
+ user = getattr(row, "user", None)
71
+ if user is None:
72
+ # Skip records that have no associated user to avoid AttributeError
73
+ # and leave them for potential manual investigation.
74
+ print(f" {model_name}: skipping record id={getattr(row, 'id', 'unknown')} with no associated user")
75
+ continue
76
+ orgs = user.organization.all()
77
if len(orgs) == 1:
78
row.org_id = orgs[0].id
79
updated += 1
80
else:
- users_with_multiple_orgs[row.user.email] = [org.name for org in orgs]
81
+ users_with_multiple_orgs[user.email] = [org.name for org in orgs]
82
83
try:
84
db.session.commit()
0 commit comments