2015-08-16 78 views
3

我试图按照关于在codeigniter中创建移植的youtube here上的codeigniter tutorail。但是,我得到了错误版本号未找到移植:1

没有迁移可以用版本号中找到:1

我已经设置$配置[ 'migration_version'] = 1;在应用程序/配置/ migration.php以及创建用户表

应用我的移民文件/迁移/ 001_Create_User.php

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

class Migration_Create_Users extends CI_Migration { 

/* 
up function is for creating and alert table 
*/ 
     public function up() 
     { 
       $this->dbforge->add_field(array(
         'id' => array(
           'type' => 'INT', 
           'constraint' => 11, 
           'unsigned' => TRUE, 
           'auto_increment' => TRUE 
         ), 
         'email' => array(
           'type' => 'VARCHAR', 
           'constraint' => '128', 
         ), 
         'password' => array(
           'type' => 'VARCHAR', 
           'constraint' => '100', 
         ), 
       )); 
       $this->dbforge->add_key('id',TRUE); 
       $this->dbforge->create_table('users'); 
     } 

/* 
down function for rollback table 
*/ 
     public function down() 
     { 
       $this->dbforge->drop_table('users'); 
     } 
} 
?> 

当我检查我的数据库,我看到了迁移表的版本始终为0 。

请帮帮我,谢谢

回答

7

在配置/ migration.php

/* 
    |-------------------------------------------------------------------------- 
    | Migration Type 
    |-------------------------------------------------------------------------- 
    | 
    | Migration file names may be based on a sequential identifier or on 
    | a timestamp. Options are: 
    | 
    | 'sequential' = Default migration naming (001_add_blog.php) 
    | 'timestamp' = Timestamp migration naming (20121031104401_add_blog.php) 
    |     Use timestamp format YYYYMMDDHHIISS. 
    | 
    | If this configuration value is missing the Migration library defaults 
    | to 'sequential' for backward compatibility. 
    | 
    */ 
    $config['migration_type'] = 'sequential';