From 6d62beca4845f2f0c439d241823fb80f83ba52cb Mon Sep 17 00:00:00 2001 From: TamarZanzouri Date: Thu, 14 Nov 2024 12:08:11 -0500 Subject: [PATCH] fix(robot-server): update data_files_table with uploaded source (#16813) --- .../persistence/_migrations/v6_to_v7.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/robot-server/robot_server/persistence/_migrations/v6_to_v7.py b/robot-server/robot_server/persistence/_migrations/v6_to_v7.py index ce528a12ab7..f2c0f2ad93d 100644 --- a/robot-server/robot_server/persistence/_migrations/v6_to_v7.py +++ b/robot-server/robot_server/persistence/_migrations/v6_to_v7.py @@ -100,16 +100,8 @@ def _migrate_data_files_table_with_new_source_col( dest_transaction: sqlalchemy.engine.Connection, ) -> None: """Add a new 'source' column to data_files table.""" - select_data_files = sqlalchemy.select(schema_7.data_files_table).order_by( - sqlite_rowid - ) - insert_new_data = sqlalchemy.insert(schema_7.data_files_table) - for old_row in dest_transaction.execute(select_data_files).all(): - dest_transaction.execute( - insert_new_data, - id=old_row.id, - name=old_row.name, - file_hash=old_row.file_hash, - created_at=old_row.created_at, - source=DataFileSourceSQLEnum.UPLOADED, + dest_transaction.execute( + sqlalchemy.update(schema_7.data_files_table).values( + {"source": DataFileSourceSQLEnum.UPLOADED} ) + )