public function getDatabase($name = null, $doFinalInitialization = true)
    {
        // this is temporary until we'll have a clean solution
        // for packaging datamodels/requiring schemas
        if ($doFinalInitialization) {
            $this->doFinalInitialization();
        }

        if (null === $name) {
            return $this->databases[0];
        }

        $db = null;
        foreach ($this->databases as $database) {
            if ($database->getName() === $name) {
                $db = $database;
                break;
            }
        }

        return $db;
    }