Add column to table if the column doesn't exist.

@param array $stmts List of SQL statements to execute for adding columns
551479
protected function _process( array $stmts )
	{
		$this->_msg( 'Adding warehouse code to order base product table', 0 );

		$table = 'mshop_order_base_product';
		$schema = $this->_getSchema( 'db-order' );

		if ( $schema->tableExists( $table ) === true &&
			$schema->columnExists( $table, 'warehousecode' ) === false )
		{
			$this->_executeList( $stmts, 'db-order' );
			$this->_status( 'done' );
		} else {
			$this->_status( 'OK' );
		}
	}
1116470
public function addColumns(array $columns)
    {
        /*
         * Build a final collection of list column objects
         */
        foreach ($columns as $columnName => $config) {
            $this->allColumns[$columnName] = $this->makeListColumn($columnName, $config);
        }
    }
1260037
protected function _process( array $stmts )
	{
		$constraint = 'unq_msprost_pid_sid';
		$table = 'mshop_product_stock';
		
		$this->_msg( 'Changing product stock unique constraint', 0 );

		if ( $this->_schema->tableExists( $table ) && $this->_schema->constraintExists( $table, $constraint ) )
		{
			$this->_executeList( $stmts );
			$this->_status( 'changed' );
		} else {
			$this->_status( 'OK' );
		}
	}
855338
public function addIndex($name, $attrs)
    {
        if (is_string($attrs)) {
            $attrs = ['type' => $attrs];
        }
        $attrs = array_intersect_key($attrs, static::$_indexKeys);
        $attrs += static::$_indexKeys;
        unset($attrs['references'], $attrs['update'], $attrs['delete']);

        if (!in_array($attrs['type'], static::$_validIndexTypes, true)) {
            throw new Exception(sprintf('Invalid index type "%s" in index "%s" in table "%s".', $attrs['type'], $name, $this->_table));
        }
        if (empty($attrs['columns'])) {
            throw new Exception(sprintf('Index "%s" in table "%s" must have at least one column.', $name, $this->_table));
        }
        $attrs['columns'] = (array)$attrs['columns'];
        foreach ($attrs['columns'] as $field) {
            if (empty($this->_columns[$field])) {
                $msg = sprintf(
                    'Columns used in index "%s" in table "%s" must be added to the Table schema first. ' .
                    'The column "%s" was not found.',
                    $name,
                    $this->_table,
                    $field
                );
                throw new Exception($msg);
            }
        }
        $this->_indexes[$name] = $attrs;

        return $this;
    }
869911
protected function _process( $stmts )
	{
		$this->_msg( 'Renameing shipping to costs in catalog index price table', 0 );

		if( $this->_schema->tableExists( 'mshop_catalog_index_price' ) === true
			&& $this->_schema->columnExists( 'mshop_catalog_index_price', 'shipping' ) === true )
		{
			$this->_execute( $stmts );
			$this->_status( 'done' );
		}
		else
		{
			$this->_status( 'OK' );
		}
	}
1302930
public function addStmt($stmt)
    {
        if (!$this->block) {
            $this->block = new CodeBlock($this->stmts);
            $this->stmts = & $this->block->stmts;
        }
        $stmt = $this->normalizeNode($stmt);
        $this->stmts[] = $stmt;
        return $this;
    }
575775
protected function _process( array $stmts )
	{
		$this->_msg( 'Removing locale constraints from supplier tables', 0 );
		$this->_status( '' );

		$schema = $this->_getSchema( 'db-supplier' );

		foreach( $stmts as $table => $list )
		{
			if( $schema->tableExists( $table ) === true )
			{
				foreach( $list as $constraint => $stmt )
				{
					$this->_msg( sprintf( 'Removing "%1$s" from "%2$s"', $constraint, $table ), 1 );

					if( $schema->constraintExists( $table, $constraint ) !== false )
					{
						$this->_execute( $stmt, 'db-supplier' );
						$this->_status( 'done' );
					} else {
						$this->_status( 'OK' );
					}
				}
			}
		}
	}
1084094
private function addColumn($sql, $alias = null, array $params = [])
    {
        $this->columns[] = [
            'sql'    => $sql,
            'alias'  => $alias,
            'params' => $params,
        ];

        return $this;
    }
490414
public function addColumns(array $columns) : Table
    {
        foreach ($columns as $column => $definition) {
            if (is_numeric($column) && is_string($definition)) {
                $this->addColumn($definition, []);
            } else {
                $this->addColumn($column, $definition);
            }
        }
        return $this;
    }
387354
public function addColumn(ColumnSchema $schema)
    {
        $key = strtolower($schema->name);

        $this->columns[$key] = $schema;
    }
808800
protected function _process( $stmt )
	{
		$table = 'madmin_log';

		$this->_msg( 'Changing site ID to NULL in madmin_log', 0 );
		$this->_status('');

		$this->_msg(sprintf('Changing table "%1$s": ', $table), 1);

		if( $this->_schema->tableExists($table) &&
			!$this->_schema->getColumnDetails( $table, 'siteid' )->isNullable() )
		{
			$this->_execute( $stmt );
			$this->_status( 'done' );
		} else {
			$this->_status( 'OK' );
		}

	}
512484
protected function addColumns(Table $table)
	{
		$stmt = $this->dbh->query("SHOW COLUMNS FROM `" . $table->getName() . "`");
		$table_quoted = $this->dbh->quote($table->getName());
		$db_quoted = $this->dbh->quote($table->getDatabase()->getName());

		while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
			$field_quoted = $this->dbh->quote($row['Field']);

			$row['Comment'] = $this->dbh->query("
				SELECT
				COLUMN_COMMENT
				FROM information_schema.COLUMNS
				WHERE TABLE_NAME=$table_quoted
					AND TABLE_SCHEMA=$db_quoted
					AND COLUMN_NAME=$field_quoted LIMIT 1")->fetchColumn();

			$name = $row['Field'];
			$is_nullable = ($row['Null'] == 'YES');
			$autoincrement = (strpos($row['Extra'], 'auto_increment') !== false);
			$size = null;
			$precision = null;
			$scale = null;

			if (preg_match('/^(\w+)[\(]?([\d,]*)[\)]?( |$)/', $row['Type'], $matches)) {
				//            colname[1]   size/precision[2]
				$nativeType = $matches[1];
				if ($matches[2]) {
					if ( ($cpos = strpos($matches[2], ',')) !== false) {
						$size = (int) substr($matches[2], 0, $cpos);
						$precision = $size;
						$scale = (int) substr($matches[2], $cpos + 1);
					} else {
						$size = (int) $matches[2];
					}
				}
				foreach (self::$defaultTypeSizes as $type => $defaultSize) {
					if ($nativeType == $type && $size == $defaultSize) {
						$size = null;
						continue;
					}
				}
			} elseif (preg_match('/^(\w+)\(/', $row['Type'], $matches)) {
				$nativeType = $matches[1];
			} else {
				$nativeType = $row['Type'];
			}

			//BLOBs can't have any default values in MySQL
			$default = preg_match('~blob|text~', $nativeType) ? null : $row['Default'];

			$propelType = $this->getMappedPropelType($nativeType);

			if (
				in_array($propelType, array(PropelTypes::INTEGER, PropelTypes::BIGINT))
				&& strpos($row['Comment'], 'timestamp') === 0
			) {
				$propelType = PropelTypes::INTEGER_TIMESTAMP;
			} elseif (!$propelType) {
				$propelType = Column::DEFAULT_TYPE;
				$this->warn("Column [" . $table->getName() . "." . $name. "] has a column type (".$nativeType.") that Propel does not support.");
			}

			$column = new Column($name);
			$column->setTable($table);
			$column->setDomainForType($propelType);
			// We may want to provide an option to include this:
			// $column->getDomain()->replaceSqlType($type);
			$column->getDomain()->replaceSize($size);
			$column->getDomain()->replaceScale($scale);
			if ($default !== null) {
				if ($propelType == PropelTypes::BOOLEAN) {
					if ($default == '1') $default = 'true';
					if ($default == '0') $default = 'false';
				}
				if (in_array($default, array('CURRENT_TIMESTAMP'))) {
					$type = ColumnDefaultValue::TYPE_EXPR;
				} else {
					$type = ColumnDefaultValue::TYPE_VALUE;
				}
				$column->getDomain()->setDefaultValue(new ColumnDefaultValue($default, $type));
			}
			$column->setAutoIncrement($autoincrement);
			$column->setNotNull(!$is_nullable);

			if ($this->addVendorInfo) {
				$vi = $this->getNewVendorInfoObject($row);
				$column->addVendorInfo($vi);
			}

			$table->addColumn($column);
		}


	}
841272
public function add($obs)
    {
        foreach ($this->_normalize($obs) as $val) {
            $this->_data[] = $val;
        }
    }
406428
protected function addCols(array $cols)
    {
        foreach ($cols as $key => $val) {
            if (is_int($key)) {
                $this->addCol($val);
            } else {
                $this->addCol($key, $val);
            }
        }
        return $this;
    }
1365933
public function addBindingsToStatement(PDOStatement $stmt, array $bindings)
    {
        foreach ($bindings as $key => &$binding) {
            $value  = &$binding;
            $type   = PDO::PARAM_STR;
            $length = -1;

            if (is_array($binding)) {
                $value  = &$binding['value'];
                $type   = array_key_exists('type', $binding) ? $binding['type'] : PDO::PARAM_STR;
                $length = array_key_exists('length', $binding) ? $binding['length'] : -1;
            }

            $stmt->bindParam(':' . $key, $value, $type, $length);
        }

        return $stmt;
    }
451957
function setColumns($columns) {
		$this->columns = array();

		if ($columns === null) {
			return $this;
		}

		if (is_string($columns)) {
			return $this->addColumn($columns);
		}

		foreach ($columns as $alias => &$column) {
			$this->addColumn($column, is_int($alias) ? null : $alias);
		}
		return $this;
	}
1143211
public function addCols(array $cols): void
    {
        // in case of a count query we don't need to a the columns:
        if ($this->isCount === true) {
            $this->statement .= ' COUNT(*)' . PHP_EOL;
            return;
        }

        if (empty($cols)) {
            return;
        }

        foreach ($cols as $i => $col) {
            $cols[$i] = $this->quoteName($col);
        }

        $this->statement .= ' ';
        $this->statement .= implode(', ', $cols);
        $this->statement .= PHP_EOL;
    }