Skip to content

Instantly share code, notes, and snippets.

@ruthlessfish
Created August 30, 2011 04:55
Show Gist options
  • Select an option

  • Save ruthlessfish/1180214 to your computer and use it in GitHub Desktop.

Select an option

Save ruthlessfish/1180214 to your computer and use it in GitHub Desktop.

Revisions

  1. ruthlessfish revised this gist Aug 30, 2011. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions migrate.php
    Original file line number Diff line number Diff line change
    @@ -14,11 +14,13 @@ public function _remap($method, $args)
    {
    $this->load->library(array('cli', 'migration'));

    // only allow version, latest and current to be called directly from the shell
    // 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');
    $args[0] OR
    $args[0] = $this->config->item('migrations_version');
    break;
    case 'latest' :
    case 'current' :
  2. ruthlessfish revised this gist Aug 30, 2011. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions migrate.php
    Original file line number Diff line number Diff line change
    @@ -14,6 +14,7 @@ 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' :
  3. ruthlessfish created this gist Aug 30, 2011.
    43 changes: 43 additions & 0 deletions migrate.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    <?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'));

    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 */