protected function indexDefString($table, array $def) {
        $indexName = $this->escape($this->buildIndexName($table, $def));
        if (empty($def['columns'])) {
            throw new \DomainException("The `$table`.$indexName index has no columns.", 500);
        }
        switch (self::val('type', $def, Db::INDEX_IX)) {
            case Db::INDEX_IX:
                return "index $indexName ".$this->bracketList($def['columns'], '`');
            case Db::INDEX_UNIQUE:
                return "unique $indexName ".$this->bracketList($def['columns'], '`');
            case Db::INDEX_PK:
                return "primary key ".$this->bracketList($def['columns'], '`');
        }
        return null;
    }