Doctrine\DBAL\Migrations\SqlFileWriter::write PHP Method

write() public method

public write ( array $queriesByVersion, string $direction ) : integer | boolean
$queriesByVersion array array Keys are versions and values are arrays of SQL queries (they must be castable to string)
$direction string
return integer | boolean
    public function write(array $queriesByVersion, $direction)
    {
        $path = $this->buildMigrationFilePath();
        $string = $this->buildMigrationFile($queriesByVersion, $direction);
        if ($this->outputWriter) {
            $this->outputWriter->write("\n" . sprintf('Writing migration file to "<info>%s</info>"', $path));
        }
        return file_put_contents($path, $string);
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Write a migration SQL file to the given path
  *
  * @param string $path The path to write the migration SQL file.
  * @param string $to   The version to migrate to.
  *
  * @return boolean $written
  */
 public function writeSqlFile($path, $to = null)
 {
     $sql = $this->getSql($to);
     $from = $this->configuration->getCurrentVersion();
     if ($to === null) {
         $to = $this->configuration->getLatestVersion();
     }
     $direction = $from > $to ? 'down' : 'up';
     $this->outputWriter->write(sprintf("# Migrating from %s to %s\n", $from, $to));
     $sqlWriter = new SqlFileWriter($this->configuration->getMigrationsTableName(), $path, $this->outputWriter);
     return $sqlWriter->write($sql, $direction);
 }
All Usage Examples Of Doctrine\DBAL\Migrations\SqlFileWriter::write