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;

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

        4.配置迁移的文件位置

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

二、迁移文件编写

如图:部分内容参考                       

数据库工厂类

数据迁移类


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

重点:

         $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);

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

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-27
  • 2022-12-23
  • 2022-12-23
  • 2021-08-03
  • 2021-12-22
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-05
  • 2021-08-23
  • 2021-07-21
  • 2022-01-30
  • 2022-03-01
相关资源
相似解决方案