public function updateSchema(array $schemaUpdateTypes, $dryRun = false)
    {
        $updateStatements = [
            SchemaUpdateType::GROUP_SAFE => $this->schemaUpdate->getSafeUpdates(),
            SchemaUpdateType::GROUP_DESTRUCTIVE => $this->schemaUpdate->getDestructiveUpdates(),
        ];

        $updateResult = new SchemaUpdateResult();

        foreach ($schemaUpdateTypes as $schemaUpdateType) {
            foreach ($schemaUpdateType->getStatementTypes() as $statementType => $statementGroup) {
                if (isset($updateStatements[$statementGroup][$statementType])) {
                    $statements = $updateStatements[$statementGroup][$statementType];
                    if (empty($statements)) {
                        continue;
                    }
                    if ($dryRun) {
                        $updateResult->addPerformedUpdates($schemaUpdateType, $statements);
                    } else {
                        $result = $this->schemaUpdate->migrate(
                            $statements,
                            // Generate a map of statements as keys and true as values
                            array_combine(array_keys($statements), array_fill(0, count($statements), true))
                        );
                        if (empty($result)) {
                            $updateResult->addPerformedUpdates($schemaUpdateType, $statements);
                        } else {
                            $updateResult->addErrors($schemaUpdateType, $result, $statements);
                        }
                    }
                }
            }
        }

        $this->emitDatabaseUpdateSignal($updateResult);

        return $updateResult;
    }
public function updateSchema(array $schemaUpdateTypes, $dryRun = false)
    {
        $updateStatements = [
            SchemaUpdateType::GROUP_SAFE => $this->schemaUpdate->getSafeUpdates(),
            SchemaUpdateType::GROUP_DESTRUCTIVE => $this->schemaUpdate->getDestructiveUpdates(),
        ];

        $updateResult = new SchemaUpdateResult();

        foreach ($schemaUpdateTypes as $schemaUpdateType) {
            foreach ($schemaUpdateType->getStatementTypes() as $statementType => $statementGroup) {
                if (isset($updateStatements[$statementGroup][$statementType])) {
                    $statements = $updateStatements[$statementGroup][$statementType];
                    if (empty($statements)) {
                        continue;
                    }
                    if ($dryRun) {
                        $updateResult->addPerformedUpdates($schemaUpdateType, $statements);
                    } else {
                        $result = $this->schemaUpdate->migrate(
                            $statements,
                            // Generate a map of statements as keys and true as values
                            array_combine(array_keys($statements), array_fill(0, count($statements), true))
                        );
                        if (empty($result)) {
                            $updateResult->addPerformedUpdates($schemaUpdateType, $statements);
                        } else {
                            $updateResult->addErrors($schemaUpdateType, $result, $statements);
                        }
                    }
                }
            }
        }

        $this->emitDatabaseUpdateSignal($updateResult);

        return $updateResult;
    }
public function updateSchema ( array $ schemaUpdateTypes , $ dryRun = false ) { $ updateStatements = [ SchemaUpdateType :: GROUP_SAFE => $ this -> schemaUpdate -> getSafeUpdates ( ) , SchemaUpdateType :: GROUP_DESTRUCTIVE => $ this -> schemaUpdate -> getDestructiveUpdates ( ) , ] ; $ updateResult = new SchemaUpdateResult ( ) ; foreach ( $ schemaUpdateTypes as $ schemaUpdateType ) { foreach ( $ schemaUpdateType -> getStatementTypes ( ) as $ statementType => $ statementGroup ) { if ( isset ( $ updateStatements [ $ statementGroup ] [ $ statementType ] ) ) { $ statements = $ updateStatements [ $ statementGroup ] [ $ statementType ] ; if ( empty ( $ statements ) ) { continue ; } if ( $ dryRun ) { $ updateResult -> addPerformedUpdates ( $ schemaUpdateType , $ statements ) ; } else { $ result = $ this -> schemaUpdate -> migrate ( $ statements , // Generate a map of statements as keys and true as values array_combine ( array_keys ( $ statements ) , array_fill ( 0 , count ( $ statements ) , true ) ) ) ; if ( empty ( $ result ) ) { $ updateResult -> addPerformedUpdates ( $ schemaUpdateType , $ statements ) ; } else { $ updateResult -> addErrors ( $ schemaUpdateType , $ result , $ statements ) ; } } } } } $ this -> emitDatabaseUpdateSignal ( $ updateResult ) ; return $ updateResult ; }
Perform necessary database schema migrations

@param SchemaUpdateType[] $schemaUpdateTypes List of permitted schema update types
@param bool $dryRun If true, the database operations are not performed
@return SchemaUpdateResult Result of the schema update
Perform necessary database schema migrations