當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Doctrine_Migration::setCurrentVersion方法代碼示例

本文整理匯總了PHP中Doctrine_Migration::setCurrentVersion方法的典型用法代碼示例。如果您正苦於以下問題:PHP Doctrine_Migration::setCurrentVersion方法的具體用法?PHP Doctrine_Migration::setCurrentVersion怎麽用?PHP Doctrine_Migration::setCurrentVersion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine_Migration的用法示例。


在下文中一共展示了Doctrine_Migration::setCurrentVersion方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testMigration

 public function testMigration()
 {
     $migration = new Doctrine_Migration('migration_classes');
     $this->assertFalse($migration->hasMigrated());
     $migration->setCurrentVersion(3);
     $migration->migrate(0);
     $this->assertEqual($migration->getCurrentVersion(), 0);
     $this->assertEqual($migration->getLatestVersion(), 4);
     $this->assertEqual($migration->getNextVersion(), 5);
     $current = $migration->getCurrentVersion();
     $migration->setCurrentVersion(100);
     $this->assertEqual($migration->getCurrentVersion(), 100);
     $migration->setCurrentVersion($current);
     $migration->migrate(3);
     $this->assertTrue($migration->hasMigrated());
     $this->assertEqual($migration->getCurrentVersion(), 3);
     $this->assertTrue($this->conn->import->tableExists('migration_phonenumber'));
     $this->assertTrue($this->conn->import->tableExists('migration_user'));
     $this->assertTrue($this->conn->import->tableExists('migration_profile'));
     $migration->migrate(4);
     $this->assertFalse($this->conn->import->tableExists('migration_profile'));
     $migration->migrate(0);
     $this->assertEqual($migration->getCurrentVersion(), 0);
     $this->assertTrue($migration->getMigrationClass(1) instanceof AddPhonenumber);
     $this->assertTrue($migration->getMigrationClass(2) instanceof AddUser);
     $this->assertTrue($migration->getMigrationClass(3) instanceof AddProfile);
     $this->assertTrue($migration->getMigrationClass(4) instanceof DropProfile);
     $this->assertFalse($this->conn->import->tableExists('migration_phonenumber'));
     $this->assertFalse($this->conn->import->tableExists('migration_user'));
     $this->assertFalse($this->conn->import->tableExists('migration_profile'));
 }
開發者ID:ninjapenguin,項目名稱:kohana-Doctrine-module,代碼行數:31,代碼來源:MigrationTestCase.php

示例2: execute

 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager($this->configuration);
     $config = $this->getCliConfig();
     $migration = new Doctrine_Migration($config['migrations_path']);
     $intValidator = new sfValidatorInteger();
     $migration->setCurrentVersion($arguments['version']);
     $this->logSection('doctrine', 'Migration version set to ' . $arguments['version']);
 }
開發者ID:bshaffer,項目名稱:Symplist,代碼行數:12,代碼來源:sfDoctrineMigrationSetTask.class.php

示例3: actionSetMigrationVersion

	/**
	 * Set a current migration version, without doing an actual migration.
	 * Useful when fixing bugs, testing etc.
	 */
	private function actionSetMigrationVersion() {
		$version = $this->getDestinationVersion();
		// Show information about current and latest available version
		$this->showMigrationVersions();
		printf("Setting migration version: %s\n", ($this->cli->command->args['version'] === null ? 'latest' : $version));
		if ($version > $this->getLatestVersion()) {
			printf("Warning: version provided (%d) greater than latest available migration (%d), Cthulhu will eat you!\n", $version, $this->getLatestVersion());
		}
		// Dry run? Stop here. If not, process.
		if ($this->cli->options['dryrun'] === true) return;
		$this->migration->setCurrentVersion($version);
	}
開發者ID:niieani,項目名稱:nandu,代碼行數:16,代碼來源:Migration.php

示例4: execute

 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     $config = $this->getCliConfig();
     $migration = new Doctrine_Migration($config['migrations_path']);
     $from = $migration->getCurrentVersion();
     $new_version = $arguments['new_version'];
     if ($new_version !== $from) {
         $migration->setCurrentVersion($new_version);
     }
     $this->log('Current migration version is ' . $new_version);
 }
開發者ID:hidenorigoto,項目名稱:sfjp-cms2,代碼行數:14,代碼來源:doctrineSetmigrationversionnumberTask.class.php

示例5: execute

 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager($this->configuration);
     $migration = new Doctrine_Migration();
     $currentVersion = $migration->getCurrentVersion();
     if (!isset($arguments['version'])) {
         $this->logSection('doctrine', 'Current migration version is ' . $currentVersion);
     } else {
         $version = $arguments['version'];
         if (!is_numeric($version)) {
             $this->logSection('doctrine', 'Unknown version ' . $version, null, 'ERROR');
             return;
         }
         $migration->setCurrentVersion($version);
         $this->logSection('doctrine', 'Current migration version was forced to ' . $version);
     }
 }
開發者ID:KnpLabs,項目名稱:knpDoctrineVersionPlugin,代碼行數:20,代碼來源:knpDoctrineVersionTask.class.php

示例6: testMigrateClearsErrors

 public function testMigrateClearsErrors()
 {
     $migration = new Doctrine_Migration('migration_classes');
     $migration->setCurrentVersion(3);
     try {
         $migration->migrate(3);
     } catch (Doctrine_Migration_Exception $e) {
         $this->assertTrue($migration->hasErrors());
         $this->assertEqual(1, $migration->getNumErrors());
     }
     try {
         $migration->migrate(3);
     } catch (Doctrine_Migration_Exception $e) {
         $this->assertTrue($migration->hasErrors());
         $this->assertEqual(1, $migration->getNumErrors());
     }
     $migration->clearErrors();
     $this->assertFalse($migration->hasErrors());
     $this->assertEqual(0, $migration->getNumErrors());
 }
開發者ID:skoop,項目名稱:doctrine1,代碼行數:20,代碼來源:MigrationTestCase.php

示例7: setCurrentVersion

 /**
  * Set the current version of the database
  *
  * @param integer $number
  * @return void
  */
 public function setCurrentVersion($number)
 {
     $this->_migration->setCurrentVersion($number);
 }
開發者ID:KasaiDot,項目名稱:FansubCMS,代碼行數:10,代碼來源:Migration.php


注:本文中的Doctrine_Migration::setCurrentVersion方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。