Updates the `content` table.

@return UpgradeToShortClassnameCommand
484469
private function updateContentTable()
    {
        $metadata = $this->em->getClassMetadata('BackBee\ClassContent\AbstractClassContent');
        $table = $metadata->getTableName();
        $field = $metadata->discriminatorColumn['name'];

        return $this->executeUpdate($table, $field);
    }
298625
public function change()
    {
        $table = $this->table('languages');
        $table->addColumn('is_rtl', 'boolean', [
            'default' => false,
            'null' => false,
        ]);
        $table->addColumn('trashed', 'datetime', [
            'default' => null,
            'null' => true,
        ]);
        $table->changeColumn('is_active', 'boolean', [
            'default' => true,
            'null' => false,
        ]);
        $table->renameColumn('short_code', 'code');
        $table->removeColumn('description');
        $table->update();
    }
573033
private function getSQLForUpdate()
    {
        $table = $this->sqlParts['from']['table'] . ($this->sqlParts['from']['alias'] ? ' ' . $this->sqlParts['from']['alias'] : '');

        return 'UPDATE ' . $table
            . ' SET ' . implode(', ', $this->sqlParts['set'])
            . ($this->sqlParts['where'] !== null ? ' WHERE ' . ((string) $this->sqlParts['where']) : '');
    }
852156
def upgrade():
    """"""
    op.create_table(
        'access_actionsroles',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('action', sa.String(length=80), nullable=True),
        sa.Column('exclude', sa.Boolean(name='exclude'), server_default='0',
                  nullable=False),
        sa.Column('argument', sa.String(length=255), nullable=True),
        sa.Column('role_id', sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(['role_id'], [u'accounts_role.id'], ),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('action', 'exclude', 'argument', 'role_id',
                            name='access_actionsroles_unique')
    )
    op.create_index(
        op.f('ix_access_actionsroles_action'), 'access_actionsroles',
        ['action'], unique=False)
    op.create_index(
        op.f('ix_access_actionsroles_argument'), 'access_actionsroles',
        ['argument'], unique=False)
    op.create_table(
        'access_actionsusers',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('action', sa.String(length=80), nullable=True),
        sa.Column('exclude', sa.Boolean(name='exclude'), server_default='0',
                  nullable=False),
        sa.Column('argument', sa.String(length=255), nullable=True),
        sa.Column('user_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(['user_id'], [u'accounts_user.id'], ),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('action', 'exclude', 'argument', 'user_id',
                            name='access_actionsusers_unique')
    )
    op.create_index(
        op.f('ix_access_actionsusers_action'), 'access_actionsusers',
        ['action'], unique=False)
    op.create_index(
        op.f('ix_access_actionsusers_argument'), 'access_actionsusers',
        ['argument'], unique=False)
92695
public function upgrade(Table $old_table)
        {
            $old_columns = $old_table->getColumns();
            $new_columns = $this->getColumns();

            $added_columns = \array_diff_key($new_columns, $old_columns);
            $altered_columns = Tools::array_diff_recursive($old_columns, $new_columns);
            $dropped_columns = \array_keys(array_diff_key($old_columns, $new_columns));

            /** @var RawQuery[] $queries */
            $queries = [];
            foreach ($added_columns as $details) {
                $queries[] = $this->getAddColumnQuery($details);
            }

            foreach ($queries as $query) {
                if ($query instanceof QueryInterface) {
                    Statement::getPreparedStatement($query)->execute();
                }
            }

            $this->migrateData($old_table);

            $queries = [];
            foreach ($altered_columns as $column => $details) {
                if (in_array($column, $dropped_columns)) continue;

                $queries[] = $this->getAlterColumnQuery($new_columns[$column]);
                $queries[] = $this->getAlterColumnDefaultQuery($new_columns[$column]);
            }
            foreach ($dropped_columns as $details) {
                $queries[] = $this->getDropColumnQuery($details);
            }
            foreach ($queries as $query) {
                if ($query instanceof RawQuery) {
                    Statement::getPreparedStatement($query)->execute();
                }
            }
        }
914610
public static function upgrade() {
		$sql = self::$sql;

		$sql::$logger->deactivate();
		try {
			$version = $sql->query(
				"SELECT version FROM meta LIMIT 1")['version'];
		} catch(SQLError $e) {
			$sql::$logger->activate();
			return self::upgrade_tables();
		}
		$sql::$logger->activate();

		if (0 <= version_compare($version, self::TABLE_VERSION))
			return self::$logger->debug(
				"Zapmin: Tables are up-to-date.");

		return self::upgrade_tables($version);
	}
739854
public GuidedDecisionTable52 upgrade(GuidedDecisionTable52 source) {

        final GuidedDecisionTable52 destination = source;

        //These are the columns we want to update
        final int iRowNumberColumnIndex = 0;
        Integer iSalienceColumnIndex = null;
        Integer iDurationColumnIndex = null;

        //Find the Salience and Duration column indexes
        List<BaseColumn> allColumns = destination.getExpandedColumns();
        for (int iCol = 0; iCol < allColumns.size(); iCol++) {
            final BaseColumn column = allColumns.get(iCol);
            if (column instanceof AttributeCol52) {
                AttributeCol52 attributeCol = (AttributeCol52) column;
                final String attributeName = attributeCol.getAttribute();
                if (GuidedDecisionTable52.SALIENCE_ATTR.equals(attributeName)) {
                    iSalienceColumnIndex = iCol;
                } else if (GuidedDecisionTable52.DURATION_ATTR.equals(attributeName)) {
                    iDurationColumnIndex = iCol;
                }
            }
        }

        //Update data-types
        for (List<DTCellValue52> row : destination.getData()) {

            //Row numbers are Integers
            final int rowNumberValue = row.get(iRowNumberColumnIndex).getNumericValue().intValue();
            row.get(iRowNumberColumnIndex).setNumericValue(rowNumberValue);

            //Salience should be an Integer
            if (iSalienceColumnIndex != null) {
                final Number salienceValue = row.get(iSalienceColumnIndex).getNumericValue();
                if (salienceValue == null) {
                    row.get(iSalienceColumnIndex).setNumericValue((Integer) null);
                } else {
                    row.get(iSalienceColumnIndex).setNumericValue(salienceValue.intValue());
                }
            }

            //Duration should be a Long
            if (iDurationColumnIndex != null) {
                final Number durationValue = row.get(iDurationColumnIndex).getNumericValue();
                if (durationValue == null) {
                    row.get(iDurationColumnIndex).setNumericValue((Long) null);
                } else {
                    row.get(iDurationColumnIndex).setNumericValue(durationValue.longValue());
                }
            }
        }

        return destination;
    }
1016803
protected function _update()
    {
        $query = $this->_queryClass;
        $bindKey = PdoBindHelper::generateBindKey();
        $result = DbConnector::getAdapter()->update((new $query)->getTableName(), $this->_truncateToStructure(true), $this->_pkWhere($bindKey), [$bindKey => $this->getInitialStateValue('id')]);
        //utrwalanie bieżącego stanu
        $this->clearModified();
        return ($result >= 0);
    }
1028096
public function updateSQL()
	{
		try{

			//check if table update values are set
			if($this->update_table['drop'] || $this->update_table['rename'])
			{
				//compose query string
				$this->query_string = ($this->update_table['drop']) ? "DROP TABLE IF EXISTS {$this->table};" : "ALTER TABLE {$this->table} RENAME TO {$this->update_table['rename']};";

				return $this;

			}

			//do column updates
			else
			{
				$lines = array();
				$template = "ALTER TABLE %s\n %s;";
				//loop through the columns available
				foreach($this->columns as $column_name => $column)
				{
					//start with less trivial goin upward ADD COLUMN complete DECIMAL(2,1) NULL AFTER description;
					if($column['add'])
					{
						$data_type = $column["type"];//set the column data type

						$length = $column["length"];//set the lenght of the data type

						$primary = ($column["primary"])	? "PRIMARY KEY " : null;//({$column_name})"; //add primary key field

						$index = ($column["index"]) ? "KEY" : null;// {$column_name} ({$column_name})"; //add index field

						switch ($data_type)
						{
							case "autonumber":

								$lines[] = "ADD COLUMN {$column_name} INT(11) NOT NULL AUTO_INCREMENT $primary AFTER {$column['add']}\n";

								break;

							case "text":

								if ($length !== null && $length <= 255)	$lines[] = "ADD COLUMN {$column_name} VARCHAR({$length}) DEFAULT NULL AFTER {$column['add']}\n";

								else $lines[] = "ADD COLUMN {$column_name} text DEFAULT NULL  AFTER {$column['add']}\n";

								break;

							case "integer":

								$lines[] = "ADD COLUMN {$column_name} INT(11) DEFAULT NULL AFTER {$column['add']}\n";

								break;

							case "decimal":

								$lines[] = "ADD COLUMN {$column_name} FLOAT DEFAULT NULL AFTER {$column['add']}\n";

								break;

							case "boolean":

								$lines[] = "ADD COLUMN {$column_name} TINYINT(4) DEFAULT NULL AFTER {$column['add']}\n";

								break;

							case "datetime":

								$lines[] = "ADD COLUMN {$column_name} DATETIME DEFAULT NULL AFTER {$column['add']}\n";

								break;

						}

					}

					elseif($column['update'])
					{

						$data_type = $column["type"];//set the column data type

						$length = $column["length"];//set the lenght of the data type

						$primary = ($column["primary"])	? "PRIMARY KEY " : null;//({$column_name})"; //add primary key field

						$index = ($column["index"]) ? "KEY" : null;// {$column_name} ({$column_name})"; //add index field

						switch ($data_type) //CHANGE COLUMN task_id task_id INT(11) NOT NULL AUTO_INCREMENT;
						{
							case "autonumber":

								$lines[] = "CHANGE COLUMN {$column_name} {$column_name} INT(11) NOT NULL AUTO_INCREMENT $primary\n";

								break;

							case "text":

								if ($length !== null && $length <= 255)	$lines[] = "ADD COLUMN {$column_name} VARCHAR({$length}) DEFAULT NULL\n";

								else $lines[] = "CHANGE COLUMN {$column_name} {$column_name} text DEFAULT NULL\n";

								break;

							case "integer":

								$lines[] = "CHANGE COLUMN {$column_name} {$column_name} INT(11) DEFAULT NULL\n";

								break;

							case "decimal":

								$lines[] = "CHANGE COLUMN {$column_name} {$column_name} FLOAT DEFAULT NULL\n";

								break;

							case "boolean":

								$lines[] = "CHANGE COLUMN {$column_name} {$column_name} TINYINT(4) DEFAULT NULL\n";

								break;

							case "datetime":

								$lines[] = "CHANGE COLUMN {$column_name} {$column_name} DATETIME DEFAULT NULL\n";

								break;

						}
	
					}

					elseif($column['rename'])
					{
						//$lines[] = "CHANGE COLUMN `{$column_name}` `{$column['rename']}`\n";
					}

					elseif($column['drop'])
					{
						$lines[] = "DROP COLUMN {$column['drop']}\n";


					}

				}

				$this->query_string = sprintf($template, $this->table, join(',',$lines));

				return $this;

			}

		}

		catch (MySLQException $err){

			$err->errorShow();

		}

	}
1209282
protected function parseUpdateStmt(){
		$sql = parent::parseUpdateStmt();
		return $this->updateLimit ? $this->applyLimit($sql . $this->clauses[3]) : $sql;
	}
1231141
private function updateSections()
    {
        $sections = $this->repo->findAll();
        foreach ($sections as $section) {
            PageListener::setSectionHasChildren($this->em, $section);
        }
        $this->em->flush();

        return $this;
    }
741169
protected function update()
  {
    $this->cfg = [];
    foreach ( $this as $key => $var ){
      if ( $key !== 'cfg' && !\is_null($var) ){
        if ( \is_array($var) ){
          foreach ( $var as $k => $v ){
            if ( !isset($this->cfg[$key]) ){
              $this->cfg[$key] = [];
            }
            if ( !\is_null($v) ){
              $this->cfg[$key][$k] = $v;
            }
          }
        }
        else{
          $this->cfg[$key] = $var;
        }
      }
    }
    return $this;
  }
193669
private function updateSectionTable()
    {
        $this->em->getConnection()->executeUpdate('SET FOREIGN_KEY_CHECKS=0');

        $schemaTool = new SchemaTool($this->em);
        $schemaManager = $this->em->getConnection()->getSchemaManager();
        $sectionMeta = $this->em->getClassMetadata('BackBee\NestedNode\Section');
        $tableSection = $sectionMeta->getTableName();

        if (false === $schemaManager->tablesExist([$tableSection])) {
            $this->output->writeln(sprintf('<info>Creating table `%s`</info>', $tableSection));
            $schemaTool->createSchema(array($sectionMeta));
        } else {
            if (false === $this->overrideExisting) {
                return $this;
            }

            $this->output->writeln(sprintf('<info>Updating table `%s`</info>',$tableSection));
            $schemaTool->updateSchema(array($sectionMeta), true);
            $this->em->getConnection()->executeUpdate(sprintf('DELETE FROM %s WHERE 1=1', $tableSection));
        }

        $query = sprintf(
                'INSERT INTO %s (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s) ',
                $tableSection,
                $this->requiredFields['uid'],
                $this->requiredFields['root_uid'],
                $this->requiredFields['parent_uid'],
                $this->requiredFields['leftnode'],
                $this->requiredFields['rightnode'],
                $this->requiredFields['level'],
                $this->requiredFields['created'],
                $this->requiredFields['modified'],
                $sectionMeta->getSingleAssociationJoinColumnName('_page'),
                $this->requiredFields['site_uid']
        );
        
        $pageMeta = $this->em->getClassMetadata('BackBee\NestedNode\Page');
        $tablePage = $pageMeta->getTableName();

        $query .= sprintf('SELECT %s, %s, %s, %s, %s, %s, %s, %s, %s, %s FROM %s WHERE %s > %s + 1',
                $this->requiredFields['uid'],
                $this->requiredFields['root_uid'],
                $this->requiredFields['parent_uid'],
                $this->requiredFields['leftnode'],
                $this->requiredFields['rightnode'],
                $this->requiredFields['level'],
                $this->requiredFields['created'],
                $this->requiredFields['modified'],
                $this->requiredFields['uid'],
                $this->requiredFields['site_uid'],
                $tablePage,
                $this->requiredFields['rightnode'],
                $this->requiredFields['leftnode']
        );

        $result = $this->em->getConnection()->executeQuery($query);
        $this->em->getConnection()->executeUpdate('SET FOREIGN_KEY_CHECKS=1');

        $this->output->writeln(sprintf(' - %d section rows created', $result->rowCount()));

        return $this;
    }
797148
public void upgradeContent(CmsObject cms) throws CmsException {

        if (m_content == null) {
            m_content = cms.readFile(m_resource).getContents();
        }
    }
125295
private function getUpdateQuery()
    {
        if (isset($this->parts['from'][0]['alias'])) {
            $fromClause = $this->parts['from'][0]['alias'].' FROM '.$this->getFromClause();
        } else {
            $fromClause = $this->parts['from'][0]['table'];
        }

        $setClause = array();

        foreach ($this->parts['set'] as $idenfier => $value) {
            $setClause[] = $this->getExpressionBuilder()->equal($idenfier, $value);
        }

        return 'UPDATE '.$fromClause.
               ' SET '.implode(', ', $setClause).
               (($this->parts['where'] !== null) ? ' WHERE '.$this->parts['where'] : null);
    }
783065
private function getUpdateClause()
	{
		$placeholders = [];

		foreach ($this->values as $key => $value) {
			$placeholders[] = sprintf('%s = %s', $key, $value);
		}

		return sprintf('UPDATE %s SET %s', $this->table, implode(', ', $placeholders));
	}
606302
protected function parseUpdateStmt(){
		$values = array();
		list($table, $where) = $this->clauses;
		foreach($this->escapeValue($this->stmt->getValues()) as $col => $value){
			$values[] = $this->parseFieldName($col) . ' = ' . $value;
		}
		$data = "\nSET " . implode(', ', $values);
		return 'UPDATE ' . $table . $data . $where;
	}