php - 找不到版本号为 : 1 的迁移

标签 php codeigniter-3

我尝试按照 youtube 上的 codeigniter 教程进行操作 here关于在 codeigniter 中创建迁移。但是,我得到了错误

No migration could be found with the version number: 1

我已经设置了$config['migration_version'] = 1;在 Application/Config/migration.php 和我用于创建用户表的迁移文件中

Application/migrations/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。

请帮帮我,谢谢

最佳答案

在 config/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';

关于php - 找不到版本号为 : 1 的迁移,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32034073/

相关文章:

javascript - 如何使用 Angular.js 和 PHP 按字母顺序显示列表

php - "Warning: mysql_query(): supplied argument is not a valid MySQL-Link"- 为什么?

php - 获取最近7天内的注册用户

php - MYSQL查询不会使用php返回数据

php - 合并 WordPress 数据库

codeigniter - 如何删除 CI3 中的 xss_clean

php - mysql查询fetch all rows匹配用户组只有一个

jquery - 使用 slider 发送电子邮件失败

php - CodeIgniter : 3. 0 通过composer迁移数据库

mysql - 如何用数据表解决Codeigniter中的搜索问题