Phil Sturgeon | 9758d84 | 2011-02-07 20:39:00 +0000 | [diff] [blame] | 1 | <?php |
| 2 | class Migrate extends CI_Controller |
| 3 | { |
| 4 | function __construct() |
| 5 | { |
| 6 | parent::__construct(); |
| 7 | |
| 8 | $this->load->library('migration'); |
| 9 | |
| 10 | /** VERY IMPORTANT - only turn this on when you need it. */ |
| 11 | // show_error('Access to this controller is blocked, turn me on when you need me.'); |
| 12 | } |
| 13 | |
| 14 | // Install up to the most up-to-date version. |
| 15 | function install() |
| 16 | { |
| 17 | if ( ! $this->migration->current()) |
| 18 | { |
| 19 | show_error($this->migration->error); |
| 20 | exit; |
| 21 | } |
| 22 | |
| 23 | echo "<br />Migration Successful<br />"; |
| 24 | } |
| 25 | |
| 26 | // This will migrate up to the configed migration version |
| 27 | function version($id = NULL) |
| 28 | { |
| 29 | // No $id supplied? Use the config version |
| 30 | $id OR $id = $this->config->item('migration_version'); |
| 31 | |
| 32 | if ( ! $this->migration->version($id)) |
| 33 | { |
| 34 | show_error($this->migration->error); |
| 35 | exit; |
| 36 | } |
| 37 | |
| 38 | echo "<br />Migration Successful<br />"; |
| 39 | } |
| 40 | } |