src/Db/SqliteDb.php
protected function createTable($tablename, array $tabledef, array $options = []) {
        $parts = [];

        // Make sure the primary key columns are defined first and in order.
        $autoinc = false;
        if (isset($tabledef['indexes']['primary'])) {
            $pkIndex = $tabledef['indexes']['primary'];
            foreach ($pkIndex['columns'] as $column) {
                $cdef = $tabledef['columns'][$column];
                $parts[] = $this->columnDefString($column, $cdef);
                $autoinc |= val('autoincrement', $cdef, false);
                unset($tabledef['columns'][$column]);
            }
        }

        foreach ($tabledef['columns'] as $name => $cdef) {
            $parts[] = $this->columnDefString($name, $cdef);
        }

        // Add the prinary key index.
        if (isset($pkIndex) && !$autoinc) {
            $parts[] = 'primary key '.$this->bracketList($pkIndex['columns'], '`');
        }

        $fullTablename = $this->backtick($this->px.$tablename);
        $sql = "create table $fullTablename (\n  ".
            implode(",\n  ", $parts).
            "\n)";

        $this->query($sql, Db::QUERY_DEFINE);

        // Add the rest of the indexes.
        foreach (val('indexes', $tabledef, []) as $index) {
            if (val('type', $index, Db::INDEX_IX) !== Db::INDEX_PK) {
                $this->createIndex($tablename, $index, $options);
            }
        }
    }
protected function createTable($tablename, array $tabledef, array $options = []) {
        $parts = [];

        // Make sure the primary key columns are defined first and in order.
        $autoinc = false;
        if (isset($tabledef['indexes']['primary'])) {
            $pkIndex = $tabledef['indexes']['primary'];
            foreach ($pkIndex['columns'] as $column) {
                $cdef = $tabledef['columns'][$column];
                $parts[] = $this->columnDefString($column, $cdef);
                $autoinc |= val('autoincrement', $cdef, false);
                unset($tabledef['columns'][$column]);
            }
        }

        foreach ($tabledef['columns'] as $name => $cdef) {
            $parts[] = $this->columnDefString($name, $cdef);
        }

        // Add the prinary key index.
        if (isset($pkIndex) && !$autoinc) {
            $parts[] = 'primary key '.$this->bracketList($pkIndex['columns'], '`');
        }

        $fullTablename = $this->backtick($this->px.$tablename);
        $sql = "create table $fullTablename (\n  ".
            implode(",\n  ", $parts).
            "\n)";

        $this->query($sql, Db::QUERY_DEFINE);

        // Add the rest of the indexes.
        foreach (val('indexes', $tabledef, []) as $index) {
            if (val('type', $index, Db::INDEX_IX) !== Db::INDEX_PK) {
                $this->createIndex($tablename, $index, $options);
            }
        }
    }
{@inheritdoc}