Specify a unique index for the table.

@param  string|array  $columns
@param  string  $name
@param  string|null  $algorithm
@return \Illuminate\Support\Fluent
13972
public function unique($columns, $name = null, $algorithm = null)
    {
        return $this->indexCommand('unique', $columns, $name, $algorithm);
    }
817499
public function column(string $name): AbstractColumn
    {
        if ($this->current->hasColumn($name)) {
            //Column already exists
            return $this->current->findColumn($name);
        }

        if ($this->initial->hasColumn($name)) {
            //Fetch from initial state (this code is required to ensure column states after schema
            //flushing)
            $column = clone $this->initial->findColumn($name);
        } else {
            $column = $this->createColumn($name);
        }

        $this->current->registerColumn($column);

        return $column;
    }
553608
public function index($columns, $name = NULL, $algorithm = NULL)
    {
        $conn = $this->connection->getConnection();
        $db = r\db($this->connection->getDatabaseName());
        $db->table($this->table)->indexCreate($column)
            ->run($conn);

        return $this;
    }
354859
public function createTable($name, $columns)
    {
        $cols = null;

        foreach ($columns as $col => $options) {
            $cols .= "\t" . $col . ' ' . implode(' ', $options) . ",\n";
        }
        $cols = substr($cols, 0, -2);

        $this->sql = "CREATE TABLE "
            . $this->prefix
            . $name
            . "\n(\n"
            . $cols
            . "\n);\n";

        if ($this->dialect == 'sqlite') {
            $this->sql = str_replace('auto_increment', '', $this->sql);
        }

        return $this;
    }
787148
public function withName(string $name) : Column
    {
        if ($this->name === $name) {
            return $this;
        }

        return new self($name, $this->type, $this->isPrimaryKey);
    }
445705
protected function indexCommand($type, $columns, $index)
    {
        $columns = (array) $columns;

        // If no name was specified for this index, we will create one using a basic
        // convention of the table name, followed by the columns, followed by an
        // index type, such as primary or index, which makes the index unique.
        if (is_null($index)) {
            $index = $this->createIndexName($type, $columns);
        }

        return $this->addCommand($type, compact('index', 'columns'));
    }
459759
public function unique($name, array $colmuns)
    {
        if (is_array($colmuns)) {
            $query = "CONSTRAINT $name UNIQUE (";
            //
            for ($i = 0; $i < Collection::count($colmuns); $i++) {
                if ($i == Collection::count($colmuns) - 1) {
                    $query .= $colmuns[$i];
                } else {
                    $query .= $colmuns[$i].',';
                }
            }
            $query .= ')';
            //
            self::$colmuns[] = $query;
        }
        //
        return $this;
    }
548483
public function dropIndex(array $columns): AbstractTable
    {
        if (empty($schema = $this->current->findIndex($columns))) {
            throw new SchemaException(
                "Undefined index ['" . join("', '", $columns) . "'] in '{$this->getName()}'"
            );
        }

        //Dropping index from current schema
        $this->current->forgetIndex($schema);

        return $this;
    }
290683
public function column($name)
    {
        $column = new ColumnSchema($this, $name);
        $this->columns[$name] = $column;
        return $column;
    }
923987
public function column(string $name, ?string $key = null): self
    {
        return new static(array_column($this->storage, $name, $key));
    }
1214394
protected function renameColumn($name, \Doctrine\DBAL\Schema\Column $col) {
		$res = "\n\t\$table->rename('$name', '".$col->getName()."');";

		return $res;
	}
357076
protected static function getAlgorithm($name)
    {
        if (!isset(self::$algorithms[$name])) {
            self::$algorithms[$name] = new $name();
        }

        return self::$algorithms[$name];
    }
1245320
protected function prepareIndexName( array $columns, &$name )
    {
        $cols = implode( ', ', $columns );
        $cols = rtrim( $cols, ', ' );

        if ( '' === $name )
        {
            $name = 'index_' . str_replace( ', ', '_', $cols );
        }

        return $cols;
    }
466184
public function addColumn($table, $name, $data)
    {

        $q = "ALTER TABLE {$table} ADD {$name}";
        $v = $data;

        if (isset($v['type'])) {
            $q .= " {$v['type']}";
            if (isset($v['length'])) {
                $q .= "({$v['length']})";
            } else {
                if ($v['type'] != 'int' && $v['type'] != 'datetime') {
                    die ("Please set length for table: {$name} - column: {$name}");
                }
            }

            if (isset($v['unsigned']) && $v['unsigned'] == true) {
                $q .= " UNSIGNED";
            }

            if (!isset($v['null']) || $v['null'] == false) {
                $q .= " NOT NULL";
            }

            if (isset($v['default'])) {
                if (is_string($v['default'])) {
                    $v['default'] = "'{$v['default']}'";
                }

                $q .= " DEFAULT {$v['default']}";
            }

            if (isset($v['ai']) && $v['ai'] == true) {
                $q .= " AUTO_INCREMENT";
            }

            if ((isset($v['unique']) && $v['unique'] == true) && (isset($v['primary']) && $v['primary'] == true)) {
                die ("Unique or Primary?");
            }

            if (isset($v['unique']) && $v['unique'] == true) {
                $q .= " UNIQUE";
            }

            if (isset($v['primary']) && $v['primary'] == true) {
                $q .= " PRIMARY KEY";
            }

            if (isset($v['after'])) {
                $q .= " AFTER {$v['after']}";
            }

        } else {
            die ("Please set type of column ");
        }

        return $this->executeQuery($q);
    }
1248278
public function renameColumn(string $column, string $name): AbstractTable
    {
        if (!$this->hasColumn($column)) {
            throw new SchemaException("Undefined column '{$column}' in '{$this->getName()}'");
        }

        //Rename operation is simple about declaring new name
        $this->column($column)->setName($name);

        return $this;
    }
435496
public function Columns($Name = '') {
      if (strlen($Name) > 0) {
         if (array_key_exists($Name, $this->_Columns))
            return $this->_Columns[$Name];
         else {
            foreach($this->_Columns as $ColName => $Def) {
               if (strcasecmp($Name, $ColName) == 0)
                  return $Def;
            }
            return NULL;
         }
      }
		return $this->_Columns;
	}
950506
public function getByName($name): Column
    {
        $lookup = array_column($this->getArrayCopy(), null, 'name');

        return $lookup[$name];
    }