Created
November 8, 2013 21:25
Revisions
-
CMCDragonkai created this gist
Nov 8, 2013 .There are no files selected for viewing
This file contains 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,82 @@ <?php class Migrate extends CI_Controller { public function __construct(){ parent::__construct(); if(!$this->input->is_cli_request()){ exit; } $this->load->library('migration'); } public function index(){ echo "Migration is initialised. Make sure this is not accessible in production!\n"; echo "Currently available migrations:\n"; print_r($this->migration->find_migrations()); } public function latest(){ if(!$this->migration->latest()){ echo $this->migration->error_string(); } echo 'Migrated to latest'; } public function current(){ if(!$this->migration->current()){ echo $this->migration->error_string(); } echo 'Migrated to current'; } public function version($num){ if(!$this->migration->version($num)){ echo $this->migration->error_string(); } echo 'Migrated to version ' . $num; } //restarts the migration from 0 to the number specified or latest public function restart($num = false){ $this->migration->version(0); if(!empty($num)){ if(!$this->migration->version($num)){ echo $this->migration->error_string(); } echo 'Restarted migration to ' . $num; }else{ if(!$this->migration->latest()){ echo $this->migration->error_string(); } echo 'Restarted migration to latest'; } } }