diff --git a/src/tribler/core/upgrade/tribler_db/migration_chain.py b/src/tribler/core/upgrade/tribler_db/migration_chain.py index 67fec010c61..3ad141001a9 100644 --- a/src/tribler/core/upgrade/tribler_db/migration_chain.py +++ b/src/tribler/core/upgrade/tribler_db/migration_chain.py @@ -1,5 +1,5 @@ import logging -from typing import Callable, Iterator, List, Optional +from typing import Callable, List, Optional from tribler.core.components.database.db.tribler_database import TriblerDatabase from tribler.core.upgrade.tribler_db.decorator import has_migration_metadata @@ -40,14 +40,9 @@ def execute(self) -> bool: if not self.db: return False - for _ in self.steps(): - ... - - return True - - def steps(self) -> Iterator: - """ Execute migrations step by step.""" for m in self.migrations: if not has_migration_metadata(m): raise NotImplementedError(f'The migration {m} should have `migration` decorator') - yield m(self.db, state_dir=self.state_dir) + m(self.db, state_dir=self.state_dir) + + return True diff --git a/src/tribler/core/upgrade/tribler_db/tests/test_migration_chain.py b/src/tribler/core/upgrade/tribler_db/tests/test_migration_chain.py index bcdab83aaf4..7feb6653deb 100644 --- a/src/tribler/core/upgrade/tribler_db/tests/test_migration_chain.py +++ b/src/tribler/core/upgrade/tribler_db/tests/test_migration_chain.py @@ -39,20 +39,6 @@ def migration99(*_, **__): # this migration should be skipped assert migration_chain.execute() assert migration_chain.db.version == 2 - # test the same execution step by step - migration_chain.db.version = 0 - steps = migration_chain.steps() - assert migration_chain.db.version == 0 - - next(steps) # migration1 completed - assert migration_chain.db.version == 1 - - next(steps) # migration2 completed - assert migration_chain.db.version == 2 - - next(steps) # migration99 skipped - assert migration_chain.db.version == 2 - @db_session def test_db_execute_no_annotation(migration_chain: TriblerDatabaseMigrationChain):