没有发现任何迁移

时间:2015-04-08 20:19:24

标签: php codeigniter migration

我在codeigniter中创建迁移。但是我收到一条错误消息,说找不到迁移。我咨询了官方codeigniter文档。但在谷歌,我找不到这个错误。

我创建了迁移文件夹并添加了以下文件。 001_Create_users.php

 <? php
 /**
  * Description of 001_create_users
  *
  * @author Isuru
  */
 class Migration_Create_users extends CI_Migration {

   public
   function up() {
     $this - > dbforge - > add_field('id');
     $this - > dbforge - > add_field(array(
       'id' => array(
         'type' => 'INT',
         'constraint' => 11,
         'unsigned' => TRUE,
         'auto_increment' => TRUE
       ),
       'email' => array(
         'type' => 'VARCHAR',
         'constraint' => '100',
       ),
       'password' => array(
         'type' => 'VARCHAR',
         'constraint' => '100',
       ),
       'name' => array(
         'type' => 'VARCHAR',
         'constraint' => '100',
       ),
     ));
     //$this->dbforge->add_key('id', TRUE);
     $this - > dbforge - > create_table('users');
   }

   public function down() {
     $this - > dbforge - > drop_table('users');
   }

 }

这是migration.php

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

/*
|--------------------------------------------------------------------------
| Enable/Disable Migrations
|--------------------------------------------------------------------------
|
| Migrations are disabled by default for security reasons.
| You should enable migrations whenever you intend to do a schema migration
| and disable it back when you're done.
|
*/
$config['migration_enabled'] = TRUE;

/*
|--------------------------------------------------------------------------
| 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'] = 'timestamp';

/*
|--------------------------------------------------------------------------
| Migrations table
|--------------------------------------------------------------------------
|
| This is the name of the table that will store the current migrations state.
| When migrations runs it will store in a database table which migration
| level the system is at. It then compares the migration level in this
| table to the $config['migration_version'] if they are not the same it
| will migrate up. This must be set.
|
*/
$config['migration_table'] = 'migrations';

/*
|--------------------------------------------------------------------------
| Auto Migrate To Latest
|--------------------------------------------------------------------------
|
| If this is set to TRUE when you load the migrations class and have
| $config['migration_enabled'] set to TRUE the system will auto migrate
| to your latest migration (whatever $config['migration_version'] is
| set to). This way you do not have to call migrations anywhere else
| in your code to have the latest migration.
|
*/
$config['migration_auto_latest'] = TRUE;

/*
|--------------------------------------------------------------------------
| Migrations version
|--------------------------------------------------------------------------
|
| This is used to set migration version that the file system should be on.
| If you run $this->migration->current() this is the version that schema will
| be upgraded / downgraded to.
|
*/
$config['migration_version'] = 1;

/*
|--------------------------------------------------------------------------
| Migrations Path
|--------------------------------------------------------------------------
|
| Path to your migrations folder.
| Typically, it will be within your application path.
| Also, writing permission is required within the migrations path.
|
*/
$config['migration_path'] = APPPATH.'migrations/';

我从昨天开始尝试找到解决方案,但我找不到解决方案。

Error

4 个答案:

答案 0 :(得分:1)

更改&#39;时间戳&#39;到&#39;顺序&#39;如果你想使用&#39; 001&#39;

答案 1 :(得分:0)

001_Create_users.php

中有拼写错误
<? php

- >

答案 2 :(得分:0)

对于版本3.1.10,正确的迁移路径是/ application / migrations。 hth

答案 3 :(得分:-1)

请确保要迁移的应用程序下的迁移文件夹的名称。 希望它有所帮助!