【问题标题】:DB schema migration tool for CodeIgniterCodeIgniter 的数据库模式迁移工具
【发布时间】:2011-07-13 22:33:35
【问题描述】:

是否有管理 MySQL 模式更改的好工具?无论是独立的,还是与 CodeIgniter 框架集成。 我是根据使用 CakePHP 的 DB 迁移工具的经验提出这个想法的,所以类似的东西会很棒。

【问题讨论】:

标签: php codeigniter database-schema


【解决方案1】:

在其他 Doctrine 项目中,有一个 Doctrine migrations 项目。

【讨论】:

  • @jlb 不,你不必使用 Symfony。 Doctrine 与其他框架和工具很好地集成。我将它与 Zend 框架一起使用
【解决方案2】:
defined('BASEPATH') OR exit('No direct script access allowed');

class Migration_Add_blog extends CI_Migration {

    public function up()
    {
        $this->dbforge->add_field(array(
            'blog_id' => array(
                'type' => 'INT',
                'constraint' => 5,
                'unsigned' => TRUE,
                'auto_increment' => TRUE
            ),
            'blog_title' => array(
                'type' => 'VARCHAR',
                'constraint' => '100',
            ),
            'blog_description' => array(
                'type' => 'TEXT',
                'null' => TRUE,
            ),
        ));

        $this->dbforge->create_table('blog');
    }

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

从http://www.codeigniter.com/userguide2/libraries/migration.html查看它

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-11-06
    • 2010-10-08
    • 2011-02-27
    • 1970-01-01
    • 1970-01-01
    • 2014-05-05
    • 2016-11-28
    • 1970-01-01
    相关资源
    最近更新 更多