Пример #1
0
 /**
  * Execute a migration against the specified Environment.
  *
  * @param string $name Environment Name
  * @param MigrationInterface $migration Migration
  * @param string $direction Direction
  * @return void
  */
 public function executeMigration($name, MigrationInterface $migration, $direction = MigrationInterface::UP)
 {
     $this->getOutput()->writeln('');
     $this->getOutput()->writeln(' ==' . ' <info>' . $migration->getVersion() . ' ' . $migration->getName() . ':</info>' . ' <comment>' . ($direction == 'up' ? 'migrating' : 'reverting') . '</comment>');
     // Execute the migration and log the time elapsed.
     $start = microtime(true);
     $this->getEnvironment($name)->executeMigration($migration, $direction);
     $end = microtime(true);
     $this->getOutput()->writeln(' ==' . ' <info>' . $migration->getVersion() . ' ' . $migration->getName() . ':</info>' . ' <comment>' . ($direction == 'up' ? 'migrated' : 'reverted') . ' ' . sprintf('%.4fs', $end - $start) . '</comment>');
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function migrated(MigrationInterface $migration, $direction, $startTime, $endTime)
 {
     if (strtolower($direction) == 'up') {
         // up
         $sql = sprintf('INSERT INTO %s (' . 'version, start_time, end_time' . ') VALUES (' . '"%s",' . '"%s",' . '"%s"' . ');', $this->getSchemaTableName(), $migration->getVersion(), $startTime, $endTime);
         $this->query($sql);
     } else {
         // down
         $sql = sprintf("DELETE FROM %s WHERE version = '%s'", $this->getSchemaTableName(), $migration->getVersion());
         $this->query($sql);
     }
     return $this;
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function migrated(MigrationInterface $migration, $direction, $startTime, $endTime)
 {
     if (strcasecmp($direction, MigrationInterface::UP) === 0) {
         // up
         $sql = sprintf('INSERT INTO %s (' . 'version, migration_name, start_time, end_time, breakpoint' . ') VALUES (' . '\'%s\',' . '\'%s\',' . '\'%s\',' . '\'%s\',' . '0' . ');', $this->getSchemaTableName(), $migration->getVersion(), substr($migration->getName(), 0, 100), $startTime, $endTime);
         $this->query($sql);
     } else {
         // down
         $sql = sprintf("DELETE FROM %s WHERE version = '%s'", $this->getSchemaTableName(), $migration->getVersion());
         $this->query($sql);
     }
     return $this;
 }
Пример #4
0
 /**
  * {@inheritdoc}
  */
 public function migrated(MigrationInterface $migration, $direction, $startTime, $endTime)
 {
     if (strcasecmp($direction, MigrationInterface::UP) === 0) {
         // up
         $sql = sprintf("INSERT INTO %s ([version], [start_time], [end_time]) VALUES ('%s', '%s', '%s');", $this->getSchemaTableName(), $migration->getVersion(), $startTime, $endTime);
         $this->query($sql);
     } else {
         // down
         $sql = sprintf("DELETE FROM %s WHERE [version] = '%s'", $this->getSchemaTableName(), $migration->getVersion());
         $this->query($sql);
     }
     return $this;
 }
Пример #5
0
 /**
  * @inheritDoc
  */
 public function toggleBreakpoint(MigrationInterface $migration)
 {
     $this->query(sprintf('UPDATE %1$s SET %2$s = CASE %2$s WHEN %3$s THEN %4$s ELSE %3$s END WHERE %5$s = \'%6$s\';', $this->getSchemaTableName(), $this->quoteColumnName('breakpoint'), $this->castToBool(true), $this->castToBool(false), $this->quoteColumnName('version'), $migration->getVersion()));
     return $this;
 }