Adds a unique index on the given columns, with the provided name if passed

 @param columns [Array<String>, Array<Symbol>, String, Symbol]
 @param index_name [String]
779067
def add_unique_index(columns, index_name = nil)
      options = { unique: true }
      options.merge!(name: index_name) if index_name # rubocop:disable Performance/RedundantMerge

      migration.add_index(table_name, columns, options)
    end
621756
def add(self, *args, **kwargs):
        

        check_uniqueness = kwargs.pop('check_uniqueness', False)
        args = self.prepare_args(args)

        for index in self._indexes:
            index.add(*args, check_uniqueness=check_uniqueness and index.handle_uniqueness, **kwargs)
            if check_uniqueness and index.handle_uniqueness:
                check_uniqueness = False
54633
Index addExprIndex(int[] col, Expression[] indexExprs, HsqlName name, boolean unique, boolean migrating, Expression predicate) {

        Index newindex;

        if (table.isEmpty(session) || table.isIndexingMutable()) {
            newindex = table.createAndAddExprIndexStructure(name, col, indexExprs, unique, migrating, false);
        } else {
            newindex = table.createIndexStructure(name, col, null, null,
                    unique, migrating, false, false).withExpressions(indexExprs);

            Table tn = table.moveDefinition(session, table.tableType, null,
                                            null, newindex, -1, 0, emptySet,
                                            emptySet);
            // for all sessions move the data
            tn.moveData(session, table, -1, 0);
            database.persistentStoreCollection.releaseStore(table);

            table = tn;

            setNewTableInSchema(table);
            updateConstraints(table, emptySet);
        }

        database.schemaManager.addSchemaObject(newindex);
        database.schemaManager.recompileDependentObjects(table);

        if (predicate != null) {
            newindex = newindex.withPredicate(predicate);
        }

        return newindex;
    }
13972
public function unique($columns, $name = null, $algorithm = null)
    {
        return $this->indexCommand('unique', $columns, $name, $algorithm);
    }
1133914
public function addUniqueIndex( $table,$columns ) {
		$table = $this->safeTable($table);
		sort($columns); //else we get multiple indexes due to order-effects
		foreach($columns as $k=>$v) {
			$columns[$k]= $this->safeColumn($v);
		}
		$r = $this->adapter->get("SHOW INDEX FROM $table");
		$name = 'UQ_'.sha1(implode(',',$columns));
		if ($r) {
			foreach($r as $i) { 
				if (strtoupper($i['Key_name'])== strtoupper($name)) {
					return;
				}
			}
		}
		$sql = "ALTER TABLE $table
                ADD CONSTRAINT UNIQUE $name (".implode(',',$columns).")";
		$this->adapter->exec($sql);
	}
550382
def create_index(self, columns, name=None, index_type="btree"):
        
        self._check_dropped()
        if not name:
            sig = "||".join(columns + [index_type])
            # This is a work-around for a bug in <=0.6.1 which would create
            # indexes based on hash() rather than a proper hash.
            key = abs(hash(sig))
            name = "ix_%s_%s" % (self.table.name, key)
            if name in self.indexes:
                return self.indexes[name]
            key = sha1(sig.encode("utf-8")).hexdigest()[:16]
            name = "ix_%s_%s" % (self.table.name, key)
        if name in self.indexes:
            return self.indexes[name]
        # self.db._acquire()
        columns = [self.table.c[col] for col in columns]
        idx = Index(name, *columns, postgresql_using=index_type)
        idx.create(self.engine)
        # finally:
        #    self.db._release()
        self.indexes[name] = idx
        return idx
1352648
public Row addColumn(int index, String name, Object value) {
        Objects.requireNonNull(name, "Name of the column cannot be null");
        Objects.requireNonNull(value, "Value of " + name + " cannot be null");
        final Column column = new Column(index, name, value);
        return this.addColumn(column);
    }
1266476
public function createIndex($indexName, $tableName, $columns)
    {
        
        $sql = 'CREATE INDEX ' . $indexName . ' ON ' . $tableName . ' (';
        $colsSql = array();
        foreach ($columns as $n => $l){
            // $n = name, $l = length
            if (!empty($l)){
                $colsSql[] =  $n . '(' . $l . ')';
            }
            else{
                $colsSql[] =  $n ;
            }
        }
    
        $colsSql = implode(',', $colsSql);
        $sql .= $colsSql . ')';
    
        $this->getDriver()->exec($sql);
        
    }
1174171
def set_index new_index_col, opts={}
      if new_index_col.respond_to?(:to_a)
        strategy = SetMultiIndexStrategy
        new_index_col = new_index_col.to_a
      else
        strategy = SetSingleIndexStrategy
      end

      uniq_size = strategy.uniq_size(self, new_index_col)
      raise ArgumentError, 'All elements in new index must be unique.' if
        @size != uniq_size

      self.index = strategy.new_index(self, new_index_col)
      strategy.delete_vector(self, new_index_col) unless opts[:keep]
      self
    end
1132154
def _add_fluent_indexes(self):
        
        for column in self._columns:
            for index in ['primary', 'unique', 'index']:
                column_index = column.get(index)

                if column_index is True:
                    getattr(self, index)(column.name)

                    break
                elif column_index:
                    getattr(self, index)(column.name, column_index)

                    break
102728
Index addIndex(int[] col, HsqlName name, boolean unique, boolean migrating, Expression predicate) {
        return addIndex(col, name, unique, migrating).withPredicate(predicate);
    }
318262
def _create_index(self, table_name, index_columns):
        

        logger.info(
            "Creating index on %s (%s)",
            table_name,
            ", ".join(index_columns))
        index_name = "%s_index_%s" % (
            table_name,
            "_".join(index_columns))
        self.connection.execute(
            "CREATE INDEX IF NOT EXISTS %s ON %s (%s)" % (
                index_name,
                table_name,
                ", ".join(index_columns)))
633905
public SQLSelect addColumnPart(final Integer _tableIndex,
                                   final String _columnName)
    {
        parts.add(new Column(tablePrefix, _tableIndex, _columnName));
        return this;
    }
936031
private int indexForColumnName(String name) {
        final Integer index = rs.getColumnNames().get(name);
        if (index == null) { return -1; }
        return ((missingColumns & (1 << index.intValue())) == 0) ? index.intValue() : -1;
    }
810529
def add_index_operation(self, name, operations):
        
        if name not in self._index_operations:
            self._add_io(name, operations)
        else:
            raise AttributeError("An index operation with the name {} was already taken".format(name))
708315
function (columns, opts) {
            opts = opts || {};
            this.constraints.push(merge({type:"unique", columns:toArray(columns)}, opts));
        }
220920
public function addIndex($columns, $unique = FALSE, $length = 20)
    {
        if (!is_array($columns))
            $columns = array($columns);
        $existingCol = $this->columns;
        foreach ($existingCol as &$col)
            $col = $col->getColumnArray();
        $allCols = array_merge($this->getCols(true), $existingCol);
        parent::_addIndex($columns, $allCols, $unique, $length);
    }