Welcome Guest, Not a member yet? Register   Sign In
CI 3 Migration Not Running?
#1

I am just getting started with using Migrations in CI 3 and I'm pretty sure I've followed the example to the letter. However, when I run my migration, no changes are made.

In my migration.php config I have

PHP Code:
$config['migration_enabled'] = TRUE
$config
['migration_type'] = 'timestamp';
$config['migration_version'] = 20161206075650

My migration file is  application/migrations/20161206075650_my_first_migration.php and looks like this:

PHP Code:
<?php

defined
('BASEPATH') OR exit('No direct script access allowed');

class 
Migration_My_first_migration extends CI_Migration {

 
  //upgrade
 
   public function up()
 
   {
 
       log_message('debug','My_first_migration UP');
 
   }

 
   //downgrade
 
   public function down()
 
   {
 
       log_message('debug','My_first_migration DOWN');
 
   }




Here is my controller function to run the migrations:

PHP Code:
       public function migrate() {
     
   $this->load->library('migration');
     
   log_message('debug','Found migrations: '.print_r($this->migration->find_migrations(),true));
     
   if($this->migration->current() === FALSE){
     
       log_message('debug','Migration Error: '.error_string());
 
               show_error($this->migration->error_string());
 
           }else{
 
               log_message('debug','Ran Migration');
 
           }
 
       

For some reason, it isn't running my migration. I get this in the logs:


Code:
INFO - 2016-12-07 10:33:55 --> Migrations Class Initialized
INFO - 2016-12-07 10:33:55 --> Language file loaded: language/english/migration_lang.php
INFO - 2016-12-07 10:33:55 --> Database Forge Class Initialized
DEBUG - 2016-12-07 10:33:55 --> Found migrations: Array
(
   [20161206075650] => /path/to/project/application/migrations/20161206075650_my_first_migration.php
)

DEBUG - 2016-12-07 10:33:55 --> Ran Migration

I checked the database too and there isn't a migrations table. I assumed this would be created automatically? I checked to make sure it's using the right database.
I tried this with the latest version of CI 3 and it's still not working. 

I've looked around the forums, various blogs and Stack Overflow posts and haven't found a solution for this.

Help would be very appreciated!
Reply
#2

Check out Craftsman CLI and forget about creating additional controllers and see the actual DB migration output, here's a demo:

[Image: 95481.png]
Reply




Theme © iAndrew 2016 - Forum software by © MyBB