def rebuild_from_transactions(self, transactions, rebuild_transaction, unarchived_form_id=None):
        already_deleted = False
        if self.case.is_deleted:
            # we exclude the transaction of the form being unarchived since it would
            # have been revoked prior to the rebuild.
            primary_transactions = [
                tx for tx in transactions
                if not tx.is_case_rebuild and tx.form_id != unarchived_form_id
            ]
            if primary_transactions:
                # already deleted means it was explicitly set to "deleted",
                # as opposed to getting set to that because it has no 'real' transactions
                already_deleted = True

        self._reset_case_state()

        real_transactions = []
        for transaction in transactions:
            if not transaction.is_relevant:
                continue
            elif transaction.is_form_transaction:
                self._apply_form_transaction(transaction)
                real_transactions.append(transaction)

        self.case.deleted = already_deleted or not bool(real_transactions)

        self.case.track_create(rebuild_transaction)
        if not self.case.modified_on:
            self.case.modified_on = rebuild_transaction.server_date
return a new :class:`.Query` with the specified options for the
dataset/ETHPy150Open dimagi/commcare-hq/corehq/form_processor/backends/sql/update_strategy.py/SqlCaseUpdateStrategy.rebuild_from_transactions--crossover with--dataset/ETHPy150Open goFrendiAsgard/kokoropy/kokoropy/packages/sqlalchemy/orm/query.py/Query.with_for_update