Skip to content

Instantly share code, notes, and snippets.

@awaidus
Created October 27, 2018 05:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awaidus/31936e63f9f85c1a2d261baf6656e843 to your computer and use it in GitHub Desktop.
Save awaidus/31936e63f9f85c1a2d261baf6656e843 to your computer and use it in GitHub Desktop.
//step-1 create Mirgrate controller in application/controller folder
<?php if ( ! defined('BASEPATH')) exit("No direct script access allowed");
class Migrate extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->input->is_cli_request()
or exit("Execute via command line: php index.php migrate");
$this->load->library('migration');
}
public function index()
{
if(!$this->migration->latest())
{
show_error($this->migration->error_string());
} else {
echo 'Migration(s) done'.PHP_EOL;
}
}
}
//step-2: Then to execute latest migration, cd into the root of the project directory and run:
php index.php migrate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment