protected function buildCodeFromSql(Configuration $configuration, array $sql): string
    {
        $currentPlatform = $configuration->getConnection()->getDatabasePlatform()->getName();
        $code = [];
        foreach ($sql as $query) {
            if (stripos($query, $configuration->getMigrationsTableName()) !== false) {
                continue;
            }
            $code[] = sprintf('$this->addSql(%s);', var_export($query, true));
        }

        if (!empty($code)) {
            array_unshift(
                $code,
                sprintf(
                    '$this->abortIf($this->connection->getDatabasePlatform()->getName() !== %s, %s);',
                    var_export($currentPlatform, true),
                    var_export(sprintf('Migration can only be executed safely on "%s".', $currentPlatform), true)
                ),
                ''
            );
        }

        return implode(chr(10), $code);
    }
protected function buildCodeFromSql(Configuration $configuration, array $sql): string
    {
        $currentPlatform = $configuration->getConnection()->getDatabasePlatform()->getName();
        $code = [];
        foreach ($sql as $query) {
            if (stripos($query, $configuration->getMigrationsTableName()) !== false) {
                continue;
            }
            $code[] = sprintf('$this->addSql(%s);', var_export($query, true));
        }

        if (!empty($code)) {
            array_unshift(
                $code,
                sprintf(
                    '$this->abortIf($this->connection->getDatabasePlatform()->getName() !== %s, %s);',
                    var_export($currentPlatform, true),
                    var_export(sprintf('Migration can only be executed safely on "%s".', $currentPlatform), true)
                ),
                ''
            );
        }

        return implode(chr(10), $code);
    }
protected function buildCodeFromSql ( Configuration $ configuration , array $ sql ) : string { $ currentPlatform = $ configuration -> getConnection ( ) -> getDatabasePlatform ( ) -> getName ( ) ; $ code = [ ] ; foreach ( $ sql as $ query ) { if ( stripos ( $ query , $ configuration -> getMigrationsTableName ( ) ) !== false ) { continue ; } $ code [ ] = sprintf ( '$this->addSql(%s);' , var_export ( $ query , true ) ) ; } if ( ! empty ( $ code ) ) { array_unshift ( $ code , sprintf ( '$this->abortIf($this->connection->getDatabasePlatform()->getName() !== %s, %s);' , var_export ( $ currentPlatform , true ) , var_export ( sprintf ( 'Migration can only be executed safely on "%s".' , $ currentPlatform ) , true ) ) , '' ) ; } return implode ( chr ( 10 ) , $ code ) ; }
Returns PHP code for a migration file that "executes" the given
array of SQL statements.

@param Configuration $configuration
@param array $sql
@return string
@throws DBALException
Returns PHP code for a migration file that executes the given array of SQL statements .