diff --git a/migrations/versions/7225d990740e_move_files_to_filesystem.py b/migrations/versions/7225d990740e_move_files_to_filesystem.py index c7769c12..dc1eb773 100644 --- a/migrations/versions/7225d990740e_move_files_to_filesystem.py +++ b/migrations/versions/7225d990740e_move_files_to_filesystem.py @@ -9,7 +9,7 @@ Create Date: 2021-12-14 10:52:50.785342 from alembic import op import sqlalchemy as sa from crc import app, session -from crc.models.file import FileModel +from crc.models.file import FileModel, FileDataModel from crc.services.file_service import FileService from crc.services.temp_migration_service import FromFilesystemService, ToFilesystemService @@ -40,7 +40,13 @@ def upgrade(): processed_files.append(file.id) # TODO: delete processed files from file_data table + for file_id in processed_files: + processed_models = session.query(FileDataModel).filter(FileDataModel.file_model_id==file_id).all() + for processed_model in processed_models: + session.delete(processed_model) + print(f'upgrade: in processed files: file_id: {file_id}') + # session.commit() print('upgrade: done: ')