Created
August 30, 2011 04:55
-
-
Save ruthlessfish/1180214 to your computer and use it in GitHub Desktop.
sample migration controller (CLI)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Sample Usage: | |
* | |
* $php index.php migrate version 5 | |
* $php index.php migrate latest | |
* $php index.php migrate current | |
* | |
*/ | |
class Migrate extends CI_Controller | |
{ | |
public function _remap($method, $args) | |
{ | |
$this->load->library(array('cli', 'migration')); | |
// only allow version, latest and current to be called | |
// directly from the shell | |
switch($method) | |
{ | |
case 'version' : | |
$args[0] OR | |
$args[0] = $this->config->item('migrations_version'); | |
break; | |
case 'latest' : | |
case 'current' : | |
break; | |
default : | |
$this->cli->write('Command not found.'); | |
exit; | |
break; | |
} | |
if( ! call_user_func_array(array($this->migration, $method), $args)) | |
{ | |
$this->cli->write($this->migration->error_string()); | |
exit; | |
} | |
$this->cli->write('Migration Successful', 'green'); | |
} | |
} // end class Migrate | |
/* End of file migrate.php */ | |
/* Location: ./application/controllers/migrate.php */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment