Adds the fields without default new in 2.00

@param array $tokenTable
@param array $missingFields
@return array Fieldname => change field commands
436042
public static function addnewAttributeFields(array $tokenTable, array $missingFields)
    {
        if (! isset($tokenTable['participant_id'])) {
            $missingFields['participant_id'] = "ADD participant_id varchar(50) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' NOT NULL";
        }
        if (! isset($tokenTable['blacklisted'])) {
            $missingFields['blacklisted'] = "ADD blacklisted varchar(17) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' NOT NULL";
        }

        return $missingFields;
    }
422348
private static void createTokenHiddenField(Controller controller, String tokenName, String tokenId) {
		StringBuilder sb = new StringBuilder();
		sb.append("<input type='hidden' name='").append(tokenName).append("' id='").append(tokenName).append("' value='").append(tokenId).append("' />");
		controller.setAttr("token", sb.toString());
	}
692810
private function addSortFields(Fieldset $fieldset)
    {
        $sortFieldsOptions = [
            ['value' => '_first', 'label' => __("First")],
            ['value' => '_last',  'label' => __("Last")],
        ];

        $fieldset->addField(
            'sort_order_asc_missing',
            'select',
            [
                'name'   => 'sort_order_asc_missing',
                'label'  => __('Sort products without value when sorting ASC'),
                'values' => $sortFieldsOptions,
                'note'   => __('How the products which are missing values for this attribute should be treated when using it to sort.'),
            ],
            'used_for_sortby'
        );

        $fieldset->addField(
            'sort_order_desc_missing',
            'select',
            [
                'name'   => 'sort_order_desc_missing',
                'label'  => __('Sort products without value when sorting DESC'),
                'values' => $sortFieldsOptions,
                'note'   => __('How the products which are missing values for this attribute should be treated when using it to sort.'),
            ],
            'sort_order_asc_missing'
        );

        return $this;
    }
148964
public static function replace(array $tokens, $newTable) {
        HashMap::assert($tokens, 'tokens');

        $operation = SqlOperation::create($tokens);
        $firstKey  = $operation === SqlOperations::DELETE || $operation === SqlOperations::SELECT ? 'FROM' : strtoupper($operation);

        $tokens[$firstKey][$operation === SqlOperations::INSERT ? 1 : 0]['no_quotes']['parts'][0] = $newTable;

        return $tokens;
    }
1371055
private function getFields($tokens, $namingConvention, $class)
    {
        $fields = [];
        $prefix = '';

        foreach ($tokens->getTokens() as $token) {
            if ($token instanceof ByToken) {
                return $prefix . $this->fieldsToSQL($fields, $class, $namingConvention);
            }

            if ($token instanceof AllToken) {
                return $prefix . $this->fieldsToSQL([], $class, $namingConvention);
            }

            if($token instanceof DistinctToken) {
                $prefix .= 'DISTINCT ';
                continue;
            }

            if ($token instanceof AndToken) {
                // Ignore and tokens as they do nothing
                continue;
            }

            if (!($token instanceof ValueToken)) {
                throw new DslSyntaxException('Unexpected token ' . $token->getName() . ' in field selector', DATADO_UNEXPECTED_TOKEN);
            }

            $fields[] = lcfirst($token->getSource());
        }

        return $prefix . $this->fieldsToSQL($fields, $class, $namingConvention);
    }
43931
protected function addUseStatements(File $phpCsFile, int $stackPointer, array $missingUses): void
    {
        $useStatements = $this->parseUseStatements($phpCsFile, $stackPointer);
        foreach ($missingUses as $missingUse) {
            if (!in_array($missingUse, $useStatements)) {
                $this->addMissingUse($phpCsFile, $stackPointer, $missingUse);
            }
        }
    }
1085385
public function updateValues(TokenInterface $token): void
    {
        try {
            $query = $this->getConnection()->createQueryBuilder();

            $schema = $this->getDatabaseSchema();
            $now    = $this->ignoreException(function (): DateTimeImmutable {
                return new DateTimeImmutable();
            });
            $dbNow  = $this->createTypedParameter($query, $now);
            $query
                ->update($this->getTableNameForWriting())
                ->where($this->getPrimaryKeyName() . '=' . $this->createTypedParameter($query, $token->getIdentifier()))
                ->set($schema->getTokensValueColumn(), $this->createTypedParameter($query, $token->getValue()))
                ->set($schema->getTokensValueCreatedAtColumn(), $dbNow);
            if ($token->getRefreshValue() !== null) {
                $query
                    ->set(
                        $schema->getTokensRefreshColumn(),
                        $this->createTypedParameter($query, $token->getRefreshValue())
                    )->set($schema->getTokensRefreshCreatedAtColumn(), $dbNow);
            }

            $numberOfUpdated = $query->execute();
            assert(is_int($numberOfUpdated) === true);
            if ($numberOfUpdated > 0) {
                $token->setValueCreatedAt($now);
                if ($token->getRefreshValue() !== null) {
                    $token->setRefreshCreatedAt($now);
                }
            }
        } /** @noinspection PhpRedundantCatchClauseInspection */ catch (DBALException $exception) {
            $message = 'Token update failed.';
            throw new RepositoryException($message, 0, $exception);
        }
    }
836497
protected function _checkTokenTable(array $tokenTable)
    {
        $missingFields = array();

        $tokenLength = $this->_extractFieldLength($tokenTable['token']['Type']);
        $token_library = $this->tracker->getTokenLibrary();
        if ($tokenLength < $token_library->getLength()) {
            $tokenLength = $token_library->getLength();
            $missingFields['token'] = 'CHANGE COLUMN `token` `token` varchar(' . $tokenLength .
                    ") CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' NULL";
        }

        foreach ($this->_attributeMap as $name => $field) {
            if (! isset($tokenTable[$field])) {
                $missingFields[$field] = 'ADD ' . $field . ' varchar(' . $this->attributeSize .
                        ") CHARACTER SET 'utf8' COLLATE 'utf8_general_ci'";
            } else {
                $attrLength = $this->_extractFieldLength($tokenTable[$field]['Type']);
                if ($attrLength < $this->attributeSize) {
                    $missingFields[$field] = "CHANGE COLUMN `$field` `$field` varchar(" .
                            $this->attributeSize .
                            ") CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' NULL";
                }
            }
        }

        return $missingFields;
    }
774744
public function setDefaultNull($fieldNames)
    {
        if (is_array($fieldNames))
        {
            foreach ($fieldNames as $field_name)
            {
                $this->setDefaultNull($field_name);
            }
        }
        else
        {
            if (isset($this->m_fields[$fieldNames]))
            {
                $this->m_fields[$fieldNames]->setDefault('NULL');
            }
            else
            {
                $err_msg = '[' . $fieldNames . '] field not found in table ' .
                           '[' . $this->m_name . '] when setting null fields';

                throw new \Exception($err_msg);
            }
        }
    }
1265847
public function updateFrontEndFields(FieldList $fields)
    {
        if (!$this->owner->ID) {
            $fields->replaceField('InheritPerms', new CheckboxField('InheritPerms', _t('Restrictable.INHERIT_PERMS', 'Inherit Permissions'), true));
        }
        
        $ownerField = $fields->fieldByName('OwnerID');
        if ($ownerField) {
            $members = singleton('DataService')->getAllMember();
            $source = array();
            if ($members) {
                $source = $members->map();
            }
            if (method_exists($ownerField, 'setSource')) {
                $ownerField->setSource($source);
            }
        }
    }
1107105
protected function alter()
    {
        $cache = $this->getCache();

        $add = [];
        $change = [];
        $drop = [];
        $keys = [];

        // Alter table add column.
        foreach ($this->getCurrentTable()->getFields() as $name => $field) {
            // ignore add field.
            if (array_key_exists($field->getName(), $cache)) {
                continue;
            }
            $add[] = implode(' ', [
                'ALTER TABLE `' . $this->getCurrentTable()->getFullTableName() . '` ADD `' . $field->getName() . '`',
                $field->getType() . '(' . $field->getLength() . ')',
                ($field->isUnsigned()) ? 'UNSIGNED' : '',
                ($field->isNullable() ? '' : ('NOT NULL')),
                ((!empty($field->getDefault()) && !$field->isIncrement() && !$field->isUnique() && !$field->isPrimary()) ? 'DEFAULT "' . $field->getDefault() . '"' : '') ,
                ($field->isPrimary()) ? 'AUTO_INCREMENT' : '',
                'COMMENT "' . $field->getComment() . '";',
            ]);
            if (null !== $field->getKey()) {
                $keys[] = implode(' ', [
                    'ALTER TABLE `' . $this->getCurrentTable()->getFullTableName() . '` ADD ' . ($field->getKey()->isPrimary() ? 'PRIMARY KEY' : $field->getKey()->getKey()),
                    '`index_' . $field->getName() . '` (' . $field->getName() . ');',
                ]);
            }

            $this->setCacheField($field);
        }

        // Alter table change column.
        foreach ($this->getCurrentTable()->getAlterFields() as $name => $field) {
            if (array_key_exists($name, $cache)) {
                if (!$cache[$name]->equal($field)) {
                    $change[] = implode(' ', [
                        'ALTER TABLE `' . $this->getCurrentTable()->getFullTableName() . '` CHANGE `' . $name . '` `' . $field->getName() . '`',
                        $field->getType() . '(' . $field->getLength() . ')',
                        ($field->isUnsigned()) ? 'UNSIGNED' : '',
                        ($field->isNullable() ? '' : ('NOT NULL')),
                        ((!empty($field->getDefault()) && !$field->isIncrement() && !$field->isUnique() && !$field->isPrimary()) ? 'DEFAULT "' . $field->getDefault() . '"' : '') ,
                        ($field->isPrimary()) ? 'AUTO_INCREMENT' : '',
                        'COMMENT "' . $field->getComment() . '";',
                    ]);
                    if (null !== $field->getKey()) {
                        $keys[] = implode(' ', [
                            'ALTER TABLE `' . $this->getCurrentTable()->getFullTableName() . '` ADD ' . ($field->getKey()->isPrimary() ? 'PRIMARY KEY' : $field->getKey()->getKey()),
                            '`index_' . $field->getName() . '` (' . $field->getName() . ');',
                        ]);
                    }

                    $this->setCacheField($field);
                }
            }
        }

        // Alter table drop column and drop map key.
        foreach ($this->getCurrentTable()->getDropFields() as $name => $field) {
            if (!array_key_exists($name, $cache)) {
                continue;
            }
            $drop[] = implode(' ', [
                'ALTER TABLE `' . $this->getCurrentTable()->getFullTableName() . '`',
                'DROP `' . $field . '`;',
            ]);

            $this->unsetCacheField($name);
        }

        $this->saveCache();

        // Sync table and cache field.
        $this->getCurrentTable()->setFields($this->fieldsCache);

        return implode(PHP_EOL, array_filter([
            implode(PHP_EOL, $add),
            implode(PHP_EOL, $change),
            implode(PHP_EOL, $drop),
            implode(PHP_EOL, $keys),
        ]));
    }
639930
public function getAlterChange($table, $field)
    {
        $table = $this->validTableName($table);

        $name = $field['field'];
        $type = $field['type'];
        if (isset($field['autoincrement']) && $field['autoincrement']) {
            $type .= ' AUTO_INCREMENT';
        }
        if (isset($field['default']) && $field['default'] !== null && $field['default'] != '') {
            $type .= ' DEFAULT \'' . $field['default'] . '\'';
        }

        return 'ALTER TABLE ' . $table . ' CHANGE `' . $name . '` `' . $name . '` ' . $type;
    }
544788
private static function _autoUpdateFromFields(&$fields)
    {
        $addKeywords = [null, null];
        $removeKeywords = [null, null];

        if (isset($fields->add) && isset($fields->add->first_word)) {
            $addKeywords[0] = $fields->add->first_word;
        }

        if (isset($fields->add) && isset($fields->add->second_word)) {
            $addKeywords[1] = $fields->add->second_word;
        }

        if (isset($fields->remove) && isset($fields->remove->first_word)) {
            $removeKeywords[0] = $fields->remove->first_word;
        }

        if (isset($fields->remove) && isset($fields->remove->second_word)) {
            $removeKeywords[1] = $fields->remove->second_word;
        }

        return new Api\GroupAutoUpdate(
            $fields->to, $addKeywords, $removeKeywords
        );
    }
1247524
public function addMandatoryField($mandatoryField)
    {
        if (!in_array((string) $mandatoryField, $this->_mandatoryFields)) {
            $this->_mandatoryFields[] = (string) $mandatoryField;
        }

        return $this;
    }
633389
protected function generateAddFieldSql( $tableName, $fieldName, ezcDbSchemaField $fieldDefinition )
    {
        if ( $fieldDefinition->notNull && $fieldDefinition->default == null ) 
        {
            $fieldDefinition->default = $this->generateDefault( $fieldDefinition->type, 0 );

        }
        $this->queries[] = "ALTER TABLE '$tableName' ADD " . $this->generateFieldSql( $fieldName, $fieldDefinition );
    }
1015888
private void addMissingSchemas(Set<String> missingSchemas) {
		if (missingSchemas.isEmpty()) {
			return;
		}
		for (String className: missingSchemas) {
			Class<?> cls;
			try {
				cls = Class.forName(className);
			} catch (ClassNotFoundException e) {
				throw DBLogger.newFatal("Invalid field type in schema", e);
			}
			//TODO primary node is not always right here...
			createSchema(cache.getSession().getPrimaryNode(), cls);
		}
	}
972573
public function getFieldsWithTableAlias($table_alias = null)
    {
        $vals = [];
        $replace = $table_alias === null ? '' : sprintf("%s.", $table_alias);

        foreach ($this->fields as $name => $definition) {
            $vals[$name] = $this->replaceToken($this->fields[$name], $replace);
        }

        return $vals;
    }