codeigniter3.16版本migration(数据工厂迁移类)的使用

codeIgniter3.16版本migration(数据工厂迁移类)的使用介绍

一、application\config 下的迁移类配置文件migration设置

1.配置migration_enabled为true,即打开migration

    $config['migration_enabled'] = TRUE;

2.配置migration的命名规则

    时间戳格式:timestamp 即 20171205150455这种形式

    序列格式:sequential 即0,1,2,3这种形式

    $config['migration_type'] = 'timestamp';

3.配置迁移的版本

    $config['migration_version'] = 20171205150455;

        4.配置迁移的文件位置

            $config['migration_path'] = APPPATH.'migrations/';

二、迁移文件编写

如图:部分内容参考                       

数据库工厂类

数据迁移类


重点:

         $this->dbforge->add_key('id', TRUE); //设置主键

         $this->dbforge->add_key('name');//设置普通索引

         //指定表的属性,MySQL 的 ENGINE和表注释

        $attributes = array('ENGINE' => 'InnoDB', 'comment' => '"后台模块表"');

        $this->dbforge->create_table('modules', TRUE, $attributes);

猜你喜欢

转载自blog.csdn.net/weixin_41292394/article/details/78728952