Adds the sequences for this database.

@param Database $database
504309
protected function addSequences(Database $database)
    {
        $searchPath = '?';
        $params = [$database->getSchema()];
        if (!$database->getSchema()) {
            $stmt = $this->dbh->query('SHOW search_path');
            $searchPathString = $stmt->fetchColumn();

            $params = [];
            $searchPath = explode(',', $searchPathString);

            foreach ($searchPath as &$path) {
                $params[] = $path;
                $path = '?';
            }
            $searchPath = implode(', ', $searchPath);
        }

        $stmt = $this->dbh->prepare("
            SELECT c.relname, n.nspname
            FROM pg_class c, pg_namespace n
            WHERE
                n.oid = c.relnamespace
            AND c.relkind = 'S'
            AND n.nspname IN ($searchPath);
        ");
        $stmt->execute($params);

        while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
            $name = $row['nspname'] . '.' . $row['relname'];
            $database->addSequence($name);
        }
    }
141746
protected function updateMedias(Database $db)
    {
        $this->write(' + Updating media documents');
        $this->write('  + Removing alts');

        $this->checkExecute($db->execute('
            db.media.update({}, {$unset: {alts: ""}}, {multi: true});
        '));
    }
716195
public static void addLevelsToDatabase(final BuildDatabase buildDatabase, final Level level) {
        // Add the level to the database
        buildDatabase.add(level);

        // Add the child levels to the database
        for (final Level childLevel : level.getChildLevels()) {
            addLevelsToDatabase(buildDatabase, childLevel);
        }
    }
297697
public function getTableSchemas($database = 'base')
    {
        $driver = $this->getDatabase($database)->getDriver();
        $connection = $this->establishConnection($database, Database::TARGET_SLAVE);
        $names = $driver->getTableNames($connection);

        $schemas = [];
        foreach ($names as $name) {
            $schemas[] = $this->getTableSchema($name, $database);
        }

        return $schemas;
    }
227401
protected function _addSequence(Sequence $sequence)
    {
        $namespaceName = $sequence->getNamespaceName();
        $seqName       = $sequence->getFullQualifiedName($this->getName());

        if (isset($this->_sequences[$seqName])) {
            throw SchemaException::sequenceAlreadyExists($seqName);
        }

        if ($namespaceName !== null
            && ! $sequence->isInDefaultNamespace($this->getName())
            && ! $this->hasNamespace($namespaceName)) {
            $this->createNamespace($namespaceName);
        }

        $this->_sequences[$seqName] = $sequence;
    }
634881
public function parse(Database $database, array $additionalTables = [])
    {
        $tableWraps = [];

        $this->parseTables($tableWraps, $database);
        foreach ($additionalTables as $table) {
            $this->parseTables($tableWraps, $database, $table);
        }

        // Now populate only columns.
        foreach ($tableWraps as $wrap) {
            $this->addColumns($wrap->table, $wrap->oid);
        }

        // Now add indexes and constraints.
        foreach ($tableWraps as $wrap) {
            $this->addForeignKeys($wrap->table, $wrap->oid);
            $this->addIndexes($wrap->table, $wrap->oid);
            $this->addPrimaryKey($wrap->table, $wrap->oid);
        }

        $this->addSequences($database);

        return count($tableWraps);
    }
359518
public function convertToDoctrineSchema(Database $database) : \Doctrine\DBAL\Schema\Schema
    {
        $schema = new Schema();

        foreach ($database->getTables() as $table) {
            $this->mapTable($schema, $table);
        }

        return $schema;
    }
406569
protected function updateFolders(Database $db)
    {
        $this->write(' + Updating media folder documents');

        $this->createFolderId($db);
        $this->createFolderPath();
        $this->updateFolderNames($db);
    }
850730
public function setDatabase(SqlInterface $database)
    {
        $this->database = $database;

        //for each row
        foreach ($this->data as $row) {
            if (!is_object($row) || !method_exists($row, __FUNCTION__)) {
                continue;
            }

            //let the row handle this
            $row->setDatabase($database);
        }

        return $this;
    }
359040
public function stopDatabase($database)
    {
        assert($this->_platform instanceof SQLAnywherePlatform);
        $this->_execSql($this->_platform->getStopDatabaseSQL($database));
    }
130102
public function init_db($db)
    {
        $engine = $db->db_provider;

        // read schema file from /SQL/*
        $fname = INSTALL_PATH . "SQL/$engine.initial.sql";
        if ($sql = @file_get_contents($fname)) {
            $db->set_option('table_prefix', $this->config['db_prefix']);
            $db->exec_script($sql);
        }
        else {
            $this->fail('DB Schema', "Cannot read the schema file: $fname");
            return false;
        }

        if ($err = $this->get_error()) {
            $this->fail('DB Schema', "Error creating database schema: $err");
            return false;
        }

        return true;
    }
707254
public static function create(Database $database)
    {
        $dotSyntax = '';

        // table nodes
        foreach ($database->getTables() as $table) {
            $columnsSyntax = '';
            foreach ($table->getColumns() as $column) {
                $attributes = '';

                if (count($column->getForeignKeys()) > 0) {
                    $attributes .= ' [FK]';
                }

                if ($column->isPrimaryKey()) {
                    $attributes .= ' [PK]';
                }

                $columnsSyntax .= sprintf('%s (%s)%s\l', $column->getName(), $column->getType(), $attributes);
            }

            $nodeSyntax = sprintf('"%s" [label="{<table>%s|<cols>%s}", shape=record];', $table->getName(), $table->getName(), $columnsSyntax);
            $dotSyntax .= "$nodeSyntax\n";
        }

        // relation nodes
        foreach ($database->getTables() as $table) {
            foreach ($table->getColumns() as $column) {
                foreach ($column->getForeignKeys() as $fk) {
                    $relationSyntax = sprintf('"%s":cols -> "%s":table [label="%s=%s"];', $table->getName(), $fk->getForeignTableName(), $column->getName(), implode(',', $fk->getForeignColumns()));
                    $dotSyntax .= "$relationSyntax\n";
                }
            }
        }

        return sprintf("digraph G {\n%s}\n", $dotSyntax);
    }
1234424
protected function connectDatabase($database)
    {
        $parameters = $this->parameters;
        $parameters['database'] = $database;
        $parameters['multipleactiveresultsets'] = 0;

        // Ensure that driver is available (required by PDO)
        if (empty($parameters['driver'])) {
            $parameters['driver'] = $this->getDatabaseServer();
        }

        // Notify connector of parameters, instructing the connector
        // to connect immediately to the Azure database
        $this->connector->connect($parameters, true);

        // Configure the connection
        $this->query('SET QUOTED_IDENTIFIER ON');
        $this->query('SET TEXTSIZE 2147483647');
    }
758967
public function setSequences(array $sequences)
    {
        $this->sequences = array();

        foreach ($sequences as $sequence) {
            $this->addSequence($sequence);
        }
    }
439300
public function create_database($database) {
		$query = 'CREATE DATABASE ' . $this->quote_identifier($database);
		$statement = $this->get_statement($query);

		$statement->execute();
	}
1148686
public function modifyDatabase()
    {
        foreach ($this->getDatabase()->getTables() as $table) {
            if (!$table->hasPrimaryKey()) {
                $b = clone $this;
                $table->addBehavior($b);
            }
        }
    }
1055660
public function addDatabase($database)
    {
        if ($database instanceof Database) {
            $platform = null;
            $database->setParentSchema($this);
            if (null === $database->getPlatform()) {
                if ($config = $this->getGeneratorConfig()) {
                    $platform = $config->getConfiguredPlatform(null, $database->getName());
                }

                $database->setPlatform($platform ? $platform : $this->platform);
            }
            $this->databases[] = $database;

            return $database;
        }

        // XML attributes array / hash
        $db = new Database();
        $db->setParentSchema($this);
        $db->loadMapping($database);

        return $this->addDatabase($db);
    }