CCM::setupSchema PHP Method

setupSchema() public method

public setupSchema ( $schema, $dropExistingKeyspaces = true )
    public function setupSchema($schema, $dropExistingKeyspaces = true)
    {
        if ($dropExistingKeyspaces) {
            if (version_compare($this->version, "3.0.0", ">=")) {
                $system_keyspaces = "system_schema.keyspaces";
            } else {
                $system_keyspaces = "system.schema_keyspaces";
            }
            $keyspaces = $this->session->execute(new SimpleStatement("SELECT keyspace_name FROM {$system_keyspaces}"));
            foreach ($keyspaces as $row) {
                $keyspace = $row['keyspace_name'];
                if ($this->startsWith("system", $keyspace)) {
                    continue;
                }
                if (!$this->isSilent) {
                    echo "DROP KEYSPACE " . $keyspace . "\n";
                }
                $this->session->execute(new SimpleStatement("DROP KEYSPACE {$keyspace}"));
            }
        }
        foreach (explode(";\n", $schema) as $cql) {
            $cql = trim($cql);
            if (empty($cql)) {
                continue;
            }
            if (!$this->isSilent) {
                echo $cql . "\n";
            }
            $this->session->execute(new SimpleStatement($cql));
        }
    }