def _get_migration_files_to_be_executed(self, current_version, destination_version, is_migration_up):
        if current_version == destination_version and not self.config.get("force_execute_old_migrations_versions", False):
            return []

        schema_migrations = self.sgdb.get_all_schema_migrations()

        # migration up
        if is_migration_up:
            available_migrations = self.db_migrate.get_all_migrations()
            remaining_migrations = Lists.subtract(available_migrations, schema_migrations)
            remaining_migrations_to_execute = [migration for migration in remaining_migrations if migration.version <= destination_version]
            return remaining_migrations_to_execute

        # migration down...
        destination_version_id = self.sgdb.get_version_id_from_version_number(destination_version)
        try:
            migration_versions = self.db_migrate.get_all_migration_versions()
        except:
            migration_versions = []
        down_migrations_to_execute = [migration for migration in schema_migrations if migration.id > destination_version_id]
        force_files = self.config.get("force_use_files_on_down", False)
        for migration in down_migrations_to_execute:
            if not migration.sql_down or force_files:
                if migration.version not in migration_versions:
                    raise Exception("impossible to migrate down: one of the versions was not found (%s)" % migration.version)
                migration_tmp = self.db_migrate.get_migration_from_version_number(migration.version)
                migration.sql_up = migration_tmp.sql_up
                migration.sql_down = migration_tmp.sql_down
                migration.file_name = migration_tmp.file_name

        down_migrations_to_execute.reverse()
        return down_migrations_to_execute
dataset/ETHPy150Open guilhermechapiewski/simple-db-migrate/simple_db_migrate/main.py/Main._get_migration_files_to_be_executed/original