Add the proper columns for a polymorphic table.

        :type name: str

        :type index_name: str
768522
def morphs(self, name, index_name=None):
        
        self.unsigned_integer("%s_id" % name)
        self.string("%s_type" % name)
        self.index(["%s_id" % name, "%s_type" % name], index_name)
587815
def _add_index(self, index):
        
        index_name = index.get_name()
        index_name = self._normalize_identifier(index_name)
        replaced_implicit_indexes = []

        for name, implicit_index in self._implicit_indexes.items():
            if implicit_index.is_fullfilled_by(index) and name in self._indexes:
                replaced_implicit_indexes.append(name)

        already_exists = (
            index_name in self._indexes
            and index_name not in replaced_implicit_indexes
            or self._primary_key_name is not False
            and index.is_primary()
        )
        if already_exists:
            raise IndexAlreadyExists(index_name, self._name)

        for name in replaced_implicit_indexes:
            del self._indexes[name]
            del self._implicit_indexes[name]

        if index.is_primary():
            self._primary_key_name = index_name

        self._indexes[index_name] = index

        return self
459456
def addColumn(self, col, index=None):
        ''
        if col:
            if index is None:
                index = len(self.columns)
            col.sheet = self
            self.columns.insert(index, col)
            return col
729232
def add_poly_index(self, i, j, k):
        
        self.idx_data.write(
            struct.pack(self.idx_fmt, i) +
            struct.pack(self.idx_fmt, j) +
            struct.pack(self.idx_fmt, k)
        )
396680
def create_column(self, name, type):
        
        self._check_dropped()
        if normalize_column_name(name) not in self._normalized_columns:
            self.op.add_column(self.table.name, Column(name, type), self.table.schema)
            self.table = self._update_table(self.table.name)
941204
def order_table_columns(table: Table, column_names: list) -> Table:
    """"""

    unordered_columns = table.column_names
    index_order = (unordered_columns.index(name) for name in column_names)
    ordered_columns = [table.columns[i] for i in index_order]
    ordered_pkey_names = [column for column in column_names
                          if column in table.primary_key_columns]
    primary_key = PrimaryKey(ordered_pkey_names)

    return Table(table.name, ordered_columns, primary_key, table.schema)
473931
def columns(table_name, name = nil)#:nodoc:
      result = show_fields_from(table_name, name)

      columns = []
      result.each do |field|
        klass = \
          if field[1] =~ GEOMETRY_REGEXP
            ActiveRecord::ConnectionAdapters::SpatialMysqlColumn
          else
            ActiveRecord::ConnectionAdapters::MysqlColumn
          end
        columns << klass.new(field[0], field[4], field[1], field[2] == "YES")
      end

      result.free
      columns
    end
650691
def addColumn(self, column):
        
        column.setSchema(self)
        self.__columns[column.name()] = column
164316
def _nice_fieldnames(all_columns, index_columns):
    ""
    non_index_columns = set(all_columns).difference(index_columns)
    return index_columns + sorted(non_index_columns)
1222601
def to_index(self, index_type, index_name, includes=None):
        
        return IndexField(self.name, self.data_type, index_type, index_name, includes)
762926
def add_columns(t0, t1):
    """"""

    for colname in t1.colnames:
        col = t1.columns[colname]
        if colname in t0.columns:
            continue
        new_col = Column(name=col.name, length=len(t0), dtype=col.dtype)  # ,
        # shape=col.shape)
        t0.add_column(new_col)
1047967
def AddTableColumns(self, table, columns):
    """"""
    table_columns = self._table_columns.setdefault(table, [])
    for attr in columns:
      if attr not in table_columns:
        table_columns.append(attr)
15173
def addIndex(self, index):
        
        index.setSchema(self)
        self.__indexes[index.name()] = index
248490
def add_column(column_name, definition)
      attributes = column_attributes(column_name, definition)
      migration.add_column(*attributes)
    end
639052
def create_index(self, columns, table_name, if_not_exists = True, unique = False, **kwargs):
    ''
    index_name = simplify(table_name) + u'_' + u'_'.join(map(simplify, columns))
    if unique:
      sql = u'CREATE UNIQUE INDEX %s ON %s (%s)'
    else:
      sql = u'CREATE INDEX %s ON %s (%s)'

    first_param = u'IF NOT EXISTS ' + index_name if if_not_exists else index_name

    params = (first_param, quote(table_name), ','.join(map(quote, columns)))
    self.execute(sql % params, **kwargs)
714157
def columnNameAt( self, index ):
        
        columns = self.columns()
        if ( 0 <= index and index < len(columns) ):
            return columns[index]
        return ''
736256
def indexes(table_name, name = nil)
      result = select_rows(<<-SQL, name)
        SELECT i.relname, d.indisunique, a.attname
          FROM pg_class t, pg_class i, pg_index d, pg_attribute a
         WHERE i.relkind = 'i'
           AND d.indexrelid = i.oid
           AND d.indisprimary = 'f'
           AND t.oid = d.indrelid
           AND t.relname = '#{table_name}'
           AND a.attrelid = t.oid
           AND ( d.indkey[0]=a.attnum OR d.indkey[1]=a.attnum
              OR d.indkey[2]=a.attnum OR d.indkey[3]=a.attnum
              OR d.indkey[4]=a.attnum OR d.indkey[5]=a.attnum
              OR d.indkey[6]=a.attnum OR d.indkey[7]=a.attnum
              OR d.indkey[8]=a.attnum OR d.indkey[9]=a.attnum )
        ORDER BY i.relname
      SQL

      current_index = nil
      indexes = []

      result.each do |row|
        if current_index != row[0]
          indexes << ::ActiveRecord::ConnectionAdapters::IndexDefinition.new(table_name, row[0], row[1] == "t", [])
          current_index = row[0]
        end

        indexes.last.columns << row[2]
      end

      indexes
    end