public function build()
    {
        // Disable PHPUnit error handling
        $oldErrorHandler = set_error_handler(null);

        // Create a temporary database, and force the connection to use UTC for time
        $dbConn = $this->getConn();
        $prefix = Environment::getEnv('SS_DATABASE_PREFIX') ?: 'ss_';
        do {
            $dbname = strtolower(sprintf('%stmpdb_%s_%s', $prefix, time(), rand(1000000, 9999999)));
        } while ($dbConn->databaseExists($dbname));

        $dbConn->selectDatabase($dbname, true);

        $this->resetDBSchema();

        // Reinstate PHPUnit error handling
        set_error_handler($oldErrorHandler);

        // Ensure test db is killed on exit
        $teardownOnExit = Config::inst()->get(static::class, 'teardown_on_exit');
        if ($teardownOnExit) {
            register_shutdown_function(function () {
                try {
                    $this->kill();
                } catch (Exception $ex) {
                    // An exception thrown while trying to remove a test database shouldn't fail a build, ignore
                }
            });
        }

        return $dbname;
    }