コード例 #1
0
ファイル: Flat.php プロジェクト: edisonnica/phpmig
 /**
  * Down
  *
  * @param Migration $migration
  * @return AdapterInterface
  */
 public function down(Migration $migration)
 {
     $versions = $this->fetchAll();
     if (!in_array($migration->getVersion(), $versions)) {
         return;
     }
     unset($versions[array_search($migration->getVersion(), $versions)]);
     $this->write($versions);
     return $this;
 }
コード例 #2
0
ファイル: Migrator.php プロジェクト: gazsp/phpmig
 /**
  * Run a migration in a particular direction
  *
  * @param Migration $migration
  * @param string $direction
  * @return void
  */
 protected function run(Migration $migration, $direction = 'up')
 {
     $direction = $direction == 'down' ? 'down' : 'up';
     $this->getOutput()->writeln(sprintf(' == <info>' . $migration->getVersion() . ' ' . $migration->getName() . '</info> ' . '<comment>' . ($direction == 'up' ? 'migrating' : 'reverting') . '</comment>'));
     $start = microtime(1);
     $migration->setContainer($this->getContainer());
     $migration->init();
     $migration->{$direction}();
     $this->getAdapter()->{$direction}($migration);
     $end = microtime(1);
     $this->getOutput()->writeln(sprintf(' == <info>' . $migration->getVersion() . ' ' . $migration->getName() . '</info> ' . '<comment>' . ($direction == 'up' ? 'migrated ' : 'reverted ') . sprintf("%.4fs", $end - $start) . '</comment>'));
 }
コード例 #3
0
 /**
  * Down
  *
  * @param \Phpmig\Migration\Migration $migration
  * @return \Phpmig\Adapter\AdapterInterface
  */
 public function down(\Phpmig\Migration\Migration $migration)
 {
     if (!$this->_hasSchema()) {
         $this->_createSchema();
     }
     $versions = $this->fetchAll();
     if (!in_array($migration->getVersion(), $versions)) {
         return $this;
     }
     unset($versions[array_search($migration->getVersion(), $versions)]);
     $this->write($versions);
     return $this;
 }
コード例 #4
0
    /**
     * @param  Migration $migration
     * @return fluent
     */
    public function down(Migration $migration)
    {
        $version = $migration->getVersion();
        $sql = <<<SQL
SELECT *
FROM migrations.migrations
WHERE version = :version
ORDER BY version
SQL;
        $version_row = $this->yo_pdo->query($sql, ['version' => $version])->fetch();
        if (!$version_row) {
            throw new Exception("Migration '{$version}' cannot be rolled back because it is not currently applied.");
        }
        $migration_reflection = new ReflectionClass(get_class($migration));
        $this->yo_pdo->insert('migrations.rollbacks', ['version' => $version_row['version'], 'migrated_at' => $version_row['migrated_at'], 'migration_hash' => $version_row['migration_hash'], 'rollback_hash' => hash_file('sha256', $migration_reflection->getFileName())]);
        $this->yo_pdo->delete('migrations.migrations', 'version = :version', ['version' => $migration->getVersion()]);
        return $this;
    }
コード例 #5
0
 public function setContainer(\ArrayAccess $container)
 {
     $this->_container = $container;
     return parent::setContainer($container);
 }
コード例 #6
0
ファイル: Sql.php プロジェクト: edisonnica/phpmig
 /**
  * Down
  *
  * @param Migration $migration
  * @return self
  */
 public function down(Migration $migration)
 {
     $sql = $this->getQuery('down');
     $this->connection->prepare($sql)->execute(array(':version' => $migration->getVersion()));
     return $this;
 }
コード例 #7
0
ファイル: SqlPgsql.php プロジェクト: ttym7993/phpmig
 /**
  * Down
  *
  * @param Migration $migration
  * @return self
  */
 public function down(Migration $migration)
 {
     $sql = "DELETE from {$this->quotedTableName()} where version = :version";
     $this->connection->prepare($sql)->execute(array(':version' => $migration->getVersion()));
     return $this;
 }
コード例 #8
0
ファイル: Db.php プロジェクト: gazsp/phpmig
 /**
  * Down
  *
  * @param Migration $migration
  * @return AdapterInterface
  */
 public function down(Migration $migration)
 {
     $this->adapter->delete($this->tableName, $this->adapter->quoteInto('version = ?', $migration->getVersion()));
     return $this;
 }
コード例 #9
0
 /**
  * @test
  */
 public function shouldRetrieveServices()
 {
     $this->migration->setContainer(new \ArrayObject(array('service' => 123)));
     $this->assertEquals(123, $this->migration->get('service'));
 }
コード例 #10
0
ファイル: DBAL.php プロジェクト: edisonnica/phpmig
 /**
  * Down
  *
  * @param Migration $migration
  * @return DBAL
  */
 public function down(Migration $migration)
 {
     $this->connection->delete($this->tableName, array('version' => $migration->getVersion()));
     return $this;
 }
コード例 #11
0
ファイル: DbAdapter.php プロジェクト: davedevelopment/phpmig
 /**
  * Down
  *
  * @param Migration $migration
  * @return AdapterInterface
  */
 public function down(Migration $migration)
 {
     $this->tableGateway()->delete(['version' => $migration->getVersion()]);
     return $this;
 }
コード例 #12
0
ファイル: Mongo.php プロジェクト: gazsp/phpmig
 /**
  * Down
  *
  * @param Migration $migration
  * @return self
  */
 public function down(Migration $migration)
 {
     $this->connection->selectCollection($this->tableName)->remove(array('version' => $migration->getVersion()));
     return $this;
 }
コード例 #13
0
ファイル: MigrationTest.php プロジェクト: gazsp/phpmig
 public function testMigrationVersion()
 {
     $this->assertEquals(1, $this->migration->getVersion());
 }
コード例 #14
0
 /**
  * Down
  *
  * @param Migration $migration
  *
  * @return AdapterInterface
  */
 public function down(Migration $migration)
 {
     $helper = $this->helper;
     $this->db->queryExecute(sprintf('DELETE FROM %s WHERE %s = \'%s\'', $helper->quote($this->tableName), $helper->quote('version'), $helper->forSql($migration->getVersion())));
     return $this;
 }
コード例 #15
0
ファイル: Db.php プロジェクト: gazsp/phpmig
 public function down(Migration $migration)
 {
     $this->connection->where('version', $migration->getVersion());
     $this->connection->delete($this->tableName);
     return $this;
 }
コード例 #16
0
ファイル: Database.php プロジェクト: davedevelopment/phpmig
 /**
  * Down
  *
  * @param Migration $migration
  * @return AdapterInterface
  */
 public function down(Migration $migration)
 {
     $this->adapter->table($this->tableName)->where('version', $migration->getVersion())->delete();
     return $this;
 }
コード例 #17
0
ファイル: SqlOci.php プロジェクト: gazsp/phpmig
 /**
  * Down
  *
  * @param Migration $migration
  *
  * @return self
  */
 public function down(Migration $migration)
 {
     $sql = 'DELETE from "' . $this->tableName . '" where "version" = :version';
     $this->connection->prepare($sql)->execute(array(':version' => $migration->getVersion()));
     return $this;
 }