thrownewException("The version option must be either a timestamp (e.g. 101129_185401)\nor the full name of a migration (e.g. m101129_185401_create_user_table).");
thrownewException("The version argument must be either a timestamp (e.g. 101129_185401)\nor the full name of a migration (e.g. m101129_185401_create_user_table).");
}
// try migrate up
$migrations=$this->getNewMigrations();
foreach($migrationsas$i=>$migration){
if(strpos($migration,$version.'_')===0){
$this->actionUp(array($i+1));
$this->actionUp($i+1);
return;
}
}
...
...
@@ -287,7 +318,7 @@ class MigrateController extends Controller
if($i===0){
echo"Already at '$originalVersion'. Nothing needs to be done.\n";
}else{
$this->actionDown(array($i));
$this->actionDown($i);
}
return;
}
...
...
@@ -296,33 +327,40 @@ class MigrateController extends Controller
thrownewException("Unable to find the version '$originalVersion'.");
}
publicfunctionactionMark($args)
/**
* Modifies the migration history to the specified version.
*
* No actual migration will be performed.
*
* ~~~
* yiic migrate/mark 101129_185401 # using timestamp
* yiic migrate/mark m101129_185401_create_user_table # using full name
* ~~~
*
* @param string $version the version at which the migration history should be marked.
* This can be either the timestamp or the full name of the migration.
* @throws Exception if the version argument is invalid or the version cannot be found.
*/
publicfunctionactionMark($version)
{
if(isset($args[0])){
$version=$args[0];
}else{
thrownewException('Please specify which version to mark to.');
thrownewException("Error: The version option must be either a timestamp (e.g. 101129_185401)\nor the full name of a migration (e.g. m101129_185401_create_user_table).");
thrownewException("The version argument must be either a timestamp (e.g. 101129_185401)\nor the full name of a migration (e.g. m101129_185401_create_user_table).");
}
$db=$this->getDb();
// try mark up
$migrations=$this->getNewMigrations();
foreach($migrationsas$i=>$migration){
if(strpos($migration,$version.'_')===0){
if($this->confirm("Set migration history at $originalVersion?")){
$command=$db->createCommand();
$command=$this->db->createCommand();
for($j=0;$j<=$i;++$j){
$command->insert($this->migrationTable,array(
'version'=>$migrations[$j],
'apply_time'=>time(),
));
))->execute();
}
echo"The migration history is set at $originalVersion.\nNo actual migration was performed.\n";
}
...
...
@@ -338,9 +376,11 @@ class MigrateController extends Controller
echo"Already at '$originalVersion'. Nothing needs to be done.\n";
}else{
if($this->confirm("Set migration history at $originalVersion?")){