protected function resolveState(MigrationInterface $migration): State
    {
        $db = $this->dbal->database($migration->getDatabase());

        //Fetch migration information from database
        $data = $this->migrationTable($migration->getDatabase())
                     ->select('id', 'time_executed')
                     ->where(['migration' => $migration->getState()->getName()])
                     ->run()->fetch();

        if (empty($data['time_executed'])) {
            return $migration->getState()->withStatus(State::STATUS_PENDING);
        }

        return $migration->getState()->withStatus(
            State::STATUS_EXECUTED,
            new \DateTime($data['time_executed'], $db->getDriver()->getTimezone())
        );
    }