<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def load_history(self):
 """Load upgrade history from database table. If upgrade table does not exists, the history is assumed to be empty. """

        if not self.history:
            query = Upgrade.query.order_by(desc(Upgrade.applied))

            for u in query.all():
                self.history[u.upgrade] = u.applied
                self.ordered_history.append(u.upgrade)