fix tests

Fix migration 030 by using raw sql to select usernames (avoid ORM selecting nonexistent columns)
This commit is contained in:
Josh Hawkins 2025-12-08 09:02:16 -06:00
parent 2a78ae4bfb
commit df8d1771e5

View File

@ -54,7 +54,9 @@ def migrate(migrator, database, fake=False, **kwargs):
# Migrate existing has_been_reviewed data to UserReviewStatus for all users
def migrate_data():
all_users = list(User.select())
# Use raw SQL to avoid ORM issues with columns that don't exist yet
cursor = database.execute_sql('SELECT "username" FROM "user"')
all_users = cursor.fetchall()
if not all_users:
return
@ -63,7 +65,7 @@ def migrate(migrator, database, fake=False, **kwargs):
)
reviewed_segment_ids = [row[0] for row in cursor.fetchall()]
# also migrate for anonymous (unauthenticated users)
usernames = [user.username for user in all_users] + ["anonymous"]
usernames = [user[0] for user in all_users] + ["anonymous"]
for segment_id in reviewed_segment_ids:
for username in usernames: