lazyrecord\schema\DeclareSchema::index PHP Method

index() protected method

'index' method helps you define index queries.
protected index ( $name, $columns = null, $using = null ) : SQLBuilder\Universal\Query\CreateIndexQuery
return SQLBuilder\Universal\Query\CreateIndexQuery
    protected function index($name, $columns = null, $using = null)
    {
        // return the cached index query object
        if (isset($this->indexes[$name])) {
            return $this->indexes[$name];
        }
        $query = $this->indexes[$name] = new CreateIndexQuery($name);
        if ($columns) {
            if (!$columns || empty($columns)) {
                throw new InvalidArgumentException('index columns must not be empty.');
            }
            $query->on($this->getTable(), (array) $columns);
        }
        if ($using) {
            $query->using($using);
        }
        return $query;
    }