MigrationVersion::initVersion PHP Method

initVersion() public method

Get a new SchemaMigration instance
public initVersion ( ) : void
return void
    public function initVersion()
    {
        $this->Version = ClassRegistry::init(array('class' => 'Migrations.SchemaMigration', 'ds' => $this->connection));
        $this->Version->setDataSource($this->connection);
    }

Usage Example

 /**
  * Clear all caches present related to models
  *
  * Before the 'after' callback method be called is needed to clear all caches.
  * Without it any model operations will use cached data instead of real/modified
  * data.
  *
  * @return void
  */
 protected function _clearCache()
 {
     // Clear the cache
     DboSource::$methodCache = array();
     $keys = Cache::configured();
     foreach ($keys as $key) {
         Cache::clear(false, $key);
     }
     ClassRegistry::flush();
     // Refresh the model, in case something changed
     if ($this->Version instanceof MigrationVersion) {
         $this->Version->initVersion();
     }
 }