Ejemplo n.º 1
0
 public function __construct(Configuration $configuration, $version, $class)
 {
     $this->_configuration = $configuration;
     $this->_outputWriter = $configuration->getOutputWriter();
     $this->_version = $version;
     $this->_class = $class;
     $this->_connection = $configuration->getConnection();
     $this->_sm = $this->_connection->getSchemaManager();
     $this->_platform = $this->_connection->getDatabasePlatform();
     $this->_migration = new $class($this);
 }
Ejemplo n.º 2
0
 private function _buildCodeFromSql(Configuration $configuration, array $sql)
 {
     $code = array();
     foreach ($sql as $query) {
         if (strpos($query, $configuration->getMigrationTableName()) !== false) {
             continue;
         }
         $code[] = "\$this->_addSql('" . $query . "');";
     }
     return implode("\n", $code);
 }
Ejemplo n.º 3
0
 protected function _generateMigration(Configuration $configuration, InputInterface $input, $version, $up = null, $down = null)
 {
     $placeHolders = array('<version>', '<up>', '<down>');
     $replacements = array($version, $up ? "        " . implode("\n        ", explode("\n", $up)) : null, $down ? "        " . implode("\n        ", explode("\n", $down)) : null);
     $code = str_replace($placeHolders, $replacements, self::$_template);
     $dir = $configuration->getNewMigrationsDirectory();
     $dir = $dir ? $dir : getcwd();
     $dir = rtrim($dir, '/');
     $path = $dir . '/Version' . $version . '.php';
     file_put_contents($path, $code);
     if ($editorCmd = $input->getOption('editor-cmd')) {
         shell_exec($editorCmd . ' ' . escapeshellarg($path));
     }
     return $path;
 }
Ejemplo n.º 4
0
 public static function configureMigrationsForBundle(Application $application, $bundle, Configuration $configuration)
 {
     $configuration->setMigrationsNamespace($bundle . '\\DoctrineMigrations');
     $dirs = $application->getKernel()->getBundleDirs();
     $tmp = str_replace('\\', '/', $bundle);
     $namespace = str_replace('/', '\\', dirname($tmp));
     $bundle = basename($tmp);
     $dir = $dirs[$namespace] . '/' . $bundle . '/DoctrineMigrations';
     $configuration->setMigrationsDirectory($dir);
     $configuration->registerMigrationsFromDirectory($dir);
     $configuration->setName($bundle . ' Migrations');
     $configuration->setMigrationsTableName(Inflector::tableize($bundle) . '_migration_versions');
 }
Ejemplo n.º 5
0
 /**
  * Construct a Migration instance
  *
  * @param Configuration $configuration  A migration Configuration instance
  */
 public function __construct(Configuration $configuration)
 {
     $this->_configuration = $configuration;
     $this->_outputWriter = $configuration->getOutputWriter();
 }