Wednesday, April 13, 2022

[FIXED] How do I run CodeIgniter migrations?

Issue

I know how to create them via http://codeigniter.com/user_guide/libraries/migration.html

But once I've created my migration files, how do I run them?


Solution

I am not sure this is the right way to do it, But It works for me.

I created a controller named migrate (controllers/migrate.php).

<?php defined("BASEPATH") or exit("No direct script access allowed");

class Migrate extends CI_Controller{

    public function index($version){
        $this->load->library("migration");

      if(!$this->migration->version($version)){
          show_error($this->migration->error_string());
      }   
    }
}

Then from browser I will call this url to execute index action in migrate controller
Eg : http://localhost/index.php/migrate/index/1



Answered By - RSK
Answer Checked By - Mildred Charles (PHPFixing Admin)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.