public function addIndex($type, ...$columns) {
        if (empty($columns)) {
            throw new \InvalidArgumentException("An index must contain at least one column.", 500);
        }

        $type = strtolower($type);

        // Look for a current index row.
        $currentIndex = null;
        foreach ($this->indexes as $i => $index) {
            if ($type !== $index['type']) {
                continue;
            }

            if ($type === Db::INDEX_PK || array_diff($index['columns'], $columns) == []) {
                $currentIndex =& $this->indexes[$i];
                break;
            }
        }

        if ($currentIndex) {
            $currentIndex['columns'] = $columns;
        } else {
            $indexDef = [
                'type' => $type,
                'columns' => $columns,
            ];
            $this->indexes[] = $indexDef;
        }

        return $this;
    }